Add comments for auth stages

This commit is contained in:
bodqhrohro 2019-12-21 02:04:47 +02:00
parent d439b7a581
commit 7a2e355111

View file

@ -164,6 +164,7 @@ func (c *Client) interactor() {
log.Debugf("%#v", state) log.Debugf("%#v", state)
switch stateType { switch stateType {
// stage 0: set login
case client.TypeAuthorizationStateWaitPhoneNumber: case client.TypeAuthorizationStateWaitPhoneNumber:
log.Warn("Logging in...") log.Warn("Logging in...")
if c.Session.Login != "" { if c.Session.Login != "" {
@ -171,12 +172,15 @@ func (c *Client) interactor() {
} else { } else {
gateway.SendMessage(c.jid, "", "Please, enter your Telegram login via /login 12345", c.xmpp) gateway.SendMessage(c.jid, "", "Please, enter your Telegram login via /login 12345", c.xmpp)
} }
// stage 1: wait for auth code
case client.TypeAuthorizationStateWaitCode: case client.TypeAuthorizationStateWaitCode:
log.Warn("Waiting for authorization code...") log.Warn("Waiting for authorization code...")
gateway.SendMessage(c.jid, "", "Please, enter authorization code via /code 12345", c.xmpp) gateway.SendMessage(c.jid, "", "Please, enter authorization code via /code 12345", c.xmpp)
// stage 2: wait for 2fa
case client.TypeAuthorizationStateWaitPassword: case client.TypeAuthorizationStateWaitPassword:
log.Warn("Waiting for 2FA password...") log.Warn("Waiting for 2FA password...")
gateway.SendMessage(c.jid, "", "Please, enter 2FA passphrase via /password 12345", c.xmpp) gateway.SendMessage(c.jid, "", "Please, enter 2FA passphrase via /password 12345", c.xmpp)
// stage 3: auth completed
case client.TypeAuthorizationStateReady: case client.TypeAuthorizationStateReady:
var err error var err error