GramJS: Handle user deactivation (#6043)
This commit is contained in:
parent
90caadef1f
commit
bcaeee1d94
@ -474,7 +474,11 @@ async function handleTerminatedSession() {
|
|||||||
shouldThrow: true,
|
shouldThrow: true,
|
||||||
});
|
});
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.errorMessage === 'AUTH_KEY_UNREGISTERED' || err.errorMessage === 'SESSION_REVOKED') {
|
if (
|
||||||
|
err.errorMessage === 'AUTH_KEY_UNREGISTERED'
|
||||||
|
|| err.errorMessage === 'SESSION_REVOKED'
|
||||||
|
|| err.errorMessage === 'USER_DEACTIVATED'
|
||||||
|
) {
|
||||||
sendApiUpdate({
|
sendApiUpdate({
|
||||||
'@type': 'updateConnectionState',
|
'@type': 'updateConnectionState',
|
||||||
connectionState: 'connectionStateBroken',
|
connectionState: 'connectionStateBroken',
|
||||||
|
|||||||
@ -3,8 +3,9 @@ import { getAccountSlotUrl } from '../../../util/multiaccount';
|
|||||||
export function navigateBack() {
|
export function navigateBack() {
|
||||||
const currentUrl = new URL(window.location.href);
|
const currentUrl = new URL(window.location.href);
|
||||||
const referrer = document.referrer ? new URL(document.referrer) : undefined;
|
const referrer = document.referrer ? new URL(document.referrer) : undefined;
|
||||||
if (referrer?.origin === currentUrl.origin && referrer.pathname === currentUrl.pathname) {
|
if (referrer?.origin === currentUrl.origin && referrer.pathname === currentUrl.pathname
|
||||||
window.history.back(); // Return to previous account with it's state
|
&& referrer.searchParams.get('account') !== currentUrl.searchParams.get('account')) {
|
||||||
|
window.location.assign(referrer); // Return to previous account with it's state
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -744,7 +744,9 @@ export default class MTProtoSender {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
// `RPCError` errors except for 'AUTH_KEY_UNREGISTERED' should be handled by the client
|
// `RPCError` errors except for 'AUTH_KEY_UNREGISTERED' should be handled by the client
|
||||||
if (e instanceof RPCError) {
|
if (e instanceof RPCError) {
|
||||||
if (e.errorMessage === 'AUTH_KEY_UNREGISTERED' || e.errorMessage === 'SESSION_REVOKED') {
|
if (e.errorMessage === 'AUTH_KEY_UNREGISTERED'
|
||||||
|
|| e.errorMessage === 'SESSION_REVOKED'
|
||||||
|
|| e.errorMessage === 'USER_DEACTIVATED') {
|
||||||
// 'AUTH_KEY_UNREGISTERED' for the main sender is thrown when unauthorized and should be ignored
|
// 'AUTH_KEY_UNREGISTERED' for the main sender is thrown when unauthorized and should be ignored
|
||||||
this._handleBadAuthKey(true);
|
this._handleBadAuthKey(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user