mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
Sso link existing user (#616)
* created and applied link-sso component * implemented linking existing user to sso * removed an unused import * created and applied link-sso component * implemented linking existing user to sso * removed an unused import * merge * added a token to the sso linking flow * [jslib] Update (5d874d0->6ab444a) (#618) * Update jslib (5d874d0->6ab444a) * Update dependency flows * created and applied link-sso component * implemented linking existing user to sso * removed an unused import * merge * added a token to the sso linking flow * implemented linking existing user to sso * removed an unused import * account for some variable shakeup in jslib for link sso * updated jslib * updated jslib * still trying to fix jslib * finally, really, truly updated jslib Co-authored-by: Vincent Salucci <26154748+vincentsalucci@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,13 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
initiateBrowserSso(code, state);
|
||||
} else {
|
||||
window.location.href = window.location.origin + '/#/sso?code=' + code + '&state=' + state;
|
||||
// Match any characters between "_returnUri='" and the next "'"
|
||||
const returnUri = extractFromRegex(state, '(?<=_returnUri=\')(.*)(?=\')');
|
||||
if (returnUri) {
|
||||
window.location.href = window.location.origin + `/#${returnUri}`;
|
||||
} else {
|
||||
window.location.href = window.location.origin + '/#/sso?code=' + code + '&state=' + state;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,3 +38,14 @@ function getQsParam(name: string) {
|
||||
function initiateBrowserSso(code: string, state: string) {
|
||||
window.postMessage({ command: 'authResult', code: code, state: state }, '*');
|
||||
}
|
||||
|
||||
function extractFromRegex(s: string, regexString: string) {
|
||||
const regex = new RegExp(regexString);
|
||||
const results = regex.exec(s);
|
||||
|
||||
if (!results) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return results[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user