Support current WebK auth
This commit is contained in:
parent
54ace14d23
commit
e314c421b6
@ -710,6 +710,8 @@ export class AppDialogsManager {
|
|||||||
|
|
||||||
private onListLengthChange = () => {
|
private onListLengthChange = () => {
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
|
if(this.filterId < 2) return;
|
||||||
|
|
||||||
const emptyFolder = this.chatList.parentElement.querySelector('.empty-folder');
|
const emptyFolder = this.chatList.parentElement.querySelector('.empty-folder');
|
||||||
if(this.scroll.loadedAll.bottom && !this.chatList.childElementCount) {
|
if(this.scroll.loadedAll.bottom && !this.chatList.childElementCount) {
|
||||||
|
@ -199,9 +199,10 @@ export class AppStateManager extends EventListenerBase<{
|
|||||||
|
|
||||||
const promises: Promise<any>[] = ALL_KEYS.map(key => stateStorage.get(key))
|
const promises: Promise<any>[] = ALL_KEYS.map(key => stateStorage.get(key))
|
||||||
.concat(sessionStorage.get('user_auth'))
|
.concat(sessionStorage.get('user_auth'))
|
||||||
|
.concat(stateStorage.get('user_auth' as any)) // support old webk format
|
||||||
.concat(storagesPromises);
|
.concat(storagesPromises);
|
||||||
|
|
||||||
Promise.all(promises).then((arr) => {
|
Promise.all(promises).then(async(arr) => {
|
||||||
/* const self = this;
|
/* const self = this;
|
||||||
const skipHandleKeys = new Set(['isProxy', 'filters', 'drafts']);
|
const skipHandleKeys = new Set(['isProxy', 'filters', 'drafts']);
|
||||||
const getHandler = (path?: string) => {
|
const getHandler = (path?: string) => {
|
||||||
@ -275,6 +276,27 @@ export class AppStateManager extends EventListenerBase<{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let shiftedWebKAuth = arr.shift() as UserAuth | number;
|
||||||
|
if(!auth && shiftedWebKAuth) { // support old webk auth
|
||||||
|
auth = shiftedWebKAuth;
|
||||||
|
const keys: string[] = ['dc', 'server_time_offset', 'xt_instance'];
|
||||||
|
for(let i = 1; i <= 5; ++i) {
|
||||||
|
keys.push(`dc${i}_server_salt`);
|
||||||
|
keys.push(`dc${i}_auth_key`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const values = await Promise.all(keys.map(key => stateStorage.get(key as any)));
|
||||||
|
keys.push('user_auth');
|
||||||
|
values.push(typeof(auth) === 'number' ? {dcID: values[0] || App.baseDcId, id: auth} : auth);
|
||||||
|
|
||||||
|
let obj: any = {};
|
||||||
|
keys.forEach((key, idx) => {
|
||||||
|
obj[key] = values[idx];
|
||||||
|
});
|
||||||
|
|
||||||
|
await sessionStorage.set(obj);
|
||||||
|
}
|
||||||
|
|
||||||
if(auth) {
|
if(auth) {
|
||||||
// ! Warning ! DON'T delete this
|
// ! Warning ! DON'T delete this
|
||||||
state.authState = {_: 'authStateSignedIn'};
|
state.authState = {_: 'authStateSignedIn'};
|
||||||
|
@ -160,7 +160,7 @@ export class ApiManager {
|
|||||||
// WebPushApiManager.forceUnsubscribe(); // WARNING
|
// WebPushApiManager.forceUnsubscribe(); // WARNING
|
||||||
const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key as any)));
|
const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key as any)));
|
||||||
|
|
||||||
const logoutPromises = [];
|
const logoutPromises: Promise<any>[] = [];
|
||||||
for(let i = 0; i < storageResult.length; i++) {
|
for(let i = 0; i < storageResult.length; i++) {
|
||||||
if(storageResult[i]) {
|
if(storageResult[i]) {
|
||||||
logoutPromises.push(this.invokeApi('auth.logOut', {}, {dcId: i + 1, ignoreErrors: true}));
|
logoutPromises.push(this.invokeApi('auth.logOut', {}, {dcId: i + 1, ignoreErrors: true}));
|
||||||
|
26
src/test_webk_auth_migration.js
Normal file
26
src/test_webk_auth_migration.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
(async function asd() {
|
||||||
|
const auth = 1;
|
||||||
|
const keys = ['dc', 'server_time_offset', 'xt_instance'];
|
||||||
|
for(let i = 1; i <= 5; ++i) {
|
||||||
|
keys.push(`dc${i}_server_salt`);
|
||||||
|
keys.push(`dc${i}_auth_key`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const values = await Promise.all(keys.map(key => appStorage.get(key)));
|
||||||
|
keys.push('user_auth');
|
||||||
|
values.push(typeof(auth) === 'number' ? {dcID: values[0] || 2, id: auth} : auth);
|
||||||
|
|
||||||
|
let obj = {};
|
||||||
|
keys.forEach((key, idx) => {
|
||||||
|
obj[key] = values[idx];
|
||||||
|
});
|
||||||
|
|
||||||
|
window.exported = obj;
|
||||||
|
console.log(obj);
|
||||||
|
})();
|
||||||
|
|
||||||
|
copy(JSON.stringify(window.exported));
|
||||||
|
|
||||||
|
|
||||||
|
var obj = JSON.parse();
|
||||||
|
appStorage.set(obj);
|
Loading…
x
Reference in New Issue
Block a user