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