Auth: Fixes for non-default DC users
This commit is contained in:
parent
a14d380647
commit
570bed3010
@ -89,7 +89,7 @@ class CallbackSession extends MemorySession {
|
||||
.keys(this._authKeys)
|
||||
.forEach((dcId) => {
|
||||
const authKey = this._authKeys[dcId];
|
||||
if (!authKey._key) return;
|
||||
if (!authKey || !authKey._key) return;
|
||||
|
||||
sessionData.keys[dcId] = authKey._key.toString('hex');
|
||||
sessionData.hashes[dcId] = authKey._hash.toString('hex');
|
||||
|
||||
@ -32,13 +32,22 @@ export function clearStoredSession() {
|
||||
}
|
||||
|
||||
export function loadStoredSession(): ApiSessionData | undefined {
|
||||
const legacySessionJson = localStorage.getItem(SESSION_USER_KEY);
|
||||
if (!legacySessionJson) return undefined;
|
||||
const userAuthJson = localStorage.getItem(SESSION_USER_KEY);
|
||||
if (!userAuthJson) return undefined;
|
||||
|
||||
const { dcID: mainDcId } = JSON.parse(legacySessionJson);
|
||||
let mainDcId: number | undefined;
|
||||
const keys: Record<number, string> = {};
|
||||
const hashes: Record<number, string> = {};
|
||||
|
||||
try {
|
||||
const userAuth = JSON.parse(userAuthJson);
|
||||
mainDcId = Number(userAuth.dcID);
|
||||
} catch (err) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
if (!mainDcId) return undefined;
|
||||
|
||||
DC_IDS.forEach((dcId) => {
|
||||
try {
|
||||
const key = localStorage.getItem(`dc${dcId}_auth_key`);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user