2021-04-08 12:19:38 +03:00
|
|
|
import { TelegramClient } from '../../client'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log out from Telegram account and optionally reset the session storage.
|
|
|
|
*
|
|
|
|
* When you log out, you can immediately log back in using
|
|
|
|
* the same {@link TelegramClient} instance.
|
|
|
|
*
|
|
|
|
* @returns On success, `true` is returned
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
export async function logOut(
|
2021-07-05 17:26:30 +03:00
|
|
|
this: TelegramClient
|
2021-04-08 12:19:38 +03:00
|
|
|
): Promise<true> {
|
|
|
|
await this.call({ _: 'auth.logOut' })
|
|
|
|
|
2021-07-05 17:26:30 +03:00
|
|
|
this._userId = null
|
|
|
|
this._isBot = false
|
|
|
|
this._pts = this._seq = this._date = undefined as any
|
|
|
|
this._selfUsername = null
|
|
|
|
this._selfChanged = true
|
|
|
|
this.storage.reset()
|
|
|
|
await this._saveStorage()
|
2021-04-08 12:19:38 +03:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|