Acquire handle from authentication.
This commit is contained in:
parent
44dea6e7b4
commit
2c6fd43aa6
@ -204,6 +204,9 @@ const SCENES = {
|
||||
case Status.Ok: {
|
||||
sessionStorage.setItem("auth", PACK.base64(data.token));
|
||||
sessionStorage.setItem("auth_secret", PACK.base64(data.secret));
|
||||
CONTEXT.Auth = {
|
||||
handle: data.handle,
|
||||
};
|
||||
LOAD_URL();
|
||||
} break;
|
||||
case Status.Error: {
|
||||
@ -1044,6 +1047,18 @@ const SCENES = {
|
||||
LOAD(SCENES.Offline);
|
||||
}
|
||||
},
|
||||
|
||||
UserProfile:class{
|
||||
constructor() {
|
||||
|
||||
}
|
||||
preload() {
|
||||
|
||||
}
|
||||
load(data) {
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function LOAD(scene, data=null) {
|
||||
|
@ -95,20 +95,29 @@ function MESSAGE(event) {
|
||||
case OpCode.Authenticate: {
|
||||
console.log("RECV Authenticate");
|
||||
|
||||
if(bytes.length - index == 26) {
|
||||
if(bytes.length - index >= 26) {
|
||||
data = {
|
||||
status:(bytes[2] << 8) + bytes[3],
|
||||
token:new Uint8Array(8),
|
||||
secret:new Uint8Array(16),
|
||||
handle:"",
|
||||
};
|
||||
index += 2;
|
||||
|
||||
// Token
|
||||
for(let i = 0; i < 8; ++i) {
|
||||
data.token[i] = bytes[index++];
|
||||
}
|
||||
|
||||
// Secret
|
||||
for(let i = 0; i < 16; ++i) {
|
||||
data.secret[i] = bytes[index++];
|
||||
}
|
||||
|
||||
// User Handle
|
||||
result = UNPACK.string(bytes, index, UNPACK.u8);
|
||||
index = result.index;
|
||||
data.handle = result.data;
|
||||
} else {
|
||||
console.error("Authenticate packet bad length:" + bytes.length);
|
||||
return;
|
||||
|
@ -167,14 +167,15 @@ const UI = {
|
||||
|
||||
bottom.push(UI.button(LANG("extras"), () => { LOAD(SCENES.Extras) }, page == "extras"));
|
||||
|
||||
if(sessionStorage.getItem("auth") !== null) {
|
||||
bottom.push(UI.button(LANG("account"), () => { }));
|
||||
if(CONTEXT.Auth !== null) {
|
||||
bottom.push(UI.button(CONTEXT.Auth.handle, () => { }));
|
||||
bottom.push(UI.button(LANG("logout"), () => {
|
||||
BADGE_UPDATE(false);
|
||||
MESSAGE_COMPOSE([
|
||||
PACK.u16(OpCode.Deauthenticate),
|
||||
]);
|
||||
sessionStorage.clear();
|
||||
CONTEXT.Auth = null;
|
||||
LOAD_URL();
|
||||
}));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user