Fix #322: German umlauts create mistakes when using them in passwords

See https://stackoverflow.com/questions/3626183/javascript-base64-encoding-utf8-string-fails-in-webkit-safari
This commit is contained in:
Thomas Basler 2022-11-09 19:42:47 +01:00
parent fbe321228a
commit 7d1cdb0536

View File

@ -28,7 +28,7 @@ export function login(username: String, password: String) {
method: 'GET',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Authorization': 'Basic ' + window.btoa(username + ':' + password)
'Authorization': 'Basic ' + btoa(unescape(encodeURIComponent(username + ':' + password))),
},
};
@ -39,7 +39,7 @@ export function login(username: String, password: String) {
if (retVal) {
// store user details and basic auth credentials in local storage
// to keep user logged in between page refreshes
retVal.authdata = window.btoa(username + ':' + password);
retVal.authdata = btoa(unescape(encodeURIComponent(username + ':' + password)));
localStorage.setItem('user', JSON.stringify(retVal));
}