Skip to content

Commit 2439120

Browse files
authored
Decode back possible Base64-encoded state in responseHandler
In PR MrSwitch#658 the property base64_state was added, to force the state param to be base64-encoded instead of URI encoded. That makes the state impossible to decode when the flow returns to the calling page, so we detect if the returned state is in base64 and decode it accordingly if so, first of all.
1 parent 75109cf commit 2439120

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/hello.js

+8
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,14 @@ hello.utils.extend(hello.utils, {
13031303
// Is this an auth relay message which needs to call the proxy?
13041304
p = _this.param(location.search);
13051305

1306+
// Decode back possible Base64-encoded state
1307+
if (p && p.state) {
1308+
const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1309+
if (base64regex.test(p.state)) {
1310+
p.state = window.atob(p.state);
1311+
}
1312+
}
1313+
13061314
// OAuth2 or OAuth1 server response?
13071315
if (p && p.state && (p.code || p.oauth_token)) {
13081316

0 commit comments

Comments
 (0)