Skip to content

Instantly share code, notes, and snippets.

@muffinresearch
Created February 23, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muffinresearch/14a07ab7e6471af4fb78 to your computer and use it in GitHub Desktop.
Save muffinresearch/14a07ab7e6471af4fb78 to your computer and use it in GitHub Desktop.
fxa-login.js.diff
diff --git a/static/js/common/fxa-login.js b/static/js/common/fxa-login.js
index 2f6428b..9ff32c4 100644
--- a/static/js/common/fxa-login.js
+++ b/static/js/common/fxa-login.js
@@ -32,13 +32,20 @@ function enableFxALogin() {
});
}
+ // utf-8 handling from https://mzl.la/1LwX2Zx
+ function utf8Tob64(str) {
+ return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
+ return String.fromCharCode('0x' + p1);
+ }));
+ }
+
function fxaLogin(opts) {
opts = opts || {};
var authConfig = {
action: 'signin',
client_id: config.clientId,
email: opts.email || config.email,
- state: config.state + ':' + urlsafe(btoa(nextPath())),
+ state: config.state + ':' + urlsafe(utf8Tob64(nextPath())),
redirectUri: config.redirectUrl,
scope: config.scope,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment