mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-09 20:00:12 +00:00
auth: use unicode b64 encoding on browser
brought over unicodeB64Encode/Decode from my other filaments project. Fixes #364.
This commit is contained in:
parent
02f4ba6e8e
commit
6347495b5b
@ -291,3 +291,16 @@ export function bindManualDropdowns() {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function unicodeB64Decode(s: string): string {
|
||||
const decoded = atob(s);
|
||||
const byteArray = Uint8Array.from(decoded, (m) => m.codePointAt(0));
|
||||
const toUnicode = new TextDecoder().decode(byteArray);
|
||||
return toUnicode;
|
||||
}
|
||||
|
||||
export function unicodeB64Encode(s: string): string {
|
||||
const encoded = new TextEncoder().encode(s);
|
||||
const bin = String.fromCodePoint(...encoded);
|
||||
return btoa(bin);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Modal } from "../modules/modal.js";
|
||||
import { toggleLoader, _post } from "../modules/common.js";
|
||||
import { toggleLoader, _post, unicodeB64Encode } from "../modules/common.js";
|
||||
|
||||
export class Login {
|
||||
loggedIn: boolean = false;
|
||||
@ -68,7 +68,7 @@ export class Login {
|
||||
const refresh = (username == "" && password == "");
|
||||
req.open("GET", this._url + (refresh ? "token/refresh" : "token/login"), true);
|
||||
if (!refresh) {
|
||||
req.setRequestHeader("Authorization", "Basic " + btoa(username + ":" + password));
|
||||
req.setRequestHeader("Authorization", "Basic " + unicodeB64Encode(username + ":" + password));
|
||||
}
|
||||
req.onreadystatechange = ((req: XMLHttpRequest, _: Event): any => {
|
||||
if (req.readyState == 4) {
|
||||
|
Loading…
Reference in New Issue
Block a user