Remove unnecessary dummy lookup for validatin the session when
logging in using email and password
MODIFY
app/app.go
app/app.go
@@ -176,16 +176,15 @@ func attemptLogin(loginScreen *ui.Login, loginMessage string, configuration *con
session, discordError = loginScreen.RequestLogin(loginMessage)
} else {
session, discordError = discordgo.NewWithToken(userAgent, configuration.Token)
- }
-
- if discordError != nil {
+ //When logging in via token, the token isn't ever validated, therefore we do a test lookup here.
+ _, discordError = session.UserGuilds(0, "", "")
+ if discordError == discordgo.ErrUnauthorized {
configuration.Token = ""
return attemptLogin(loginScreen, fmt.Sprintf("Error during last login attempt:\n\n[red]%s", discordError), configuration)
}
+ }
- //When logging in via token, the token isn't ever validated, therefore we do a test lookup here.
- _, discordError = session.UserGuilds(0, "", "")
- if discordError == discordgo.ErrUnauthorized {
+ if discordError != nil {
configuration.Token = ""
return attemptLogin(loginScreen, fmt.Sprintf("Error during last login attempt:\n\n[red]%s", discordError), configuration)
}

MODIFY
ui/login.go
ui/login.go
@@ -308,7 +308,13 @@ func (login *Login) attemptLogin() {
panic("Was in state loginType=None during login attempt.")
case Token:
session, loginError := discordgo.NewWithToken(userAgent, login.tokenInput.GetText())
+ if loginError != nil || session == nil {
login.sessionChannel <- &loginAttempt{session, loginError}
+ } else {
+ //Dummy lookup for validating the token.
+ _, loginError = session.UserGuilds(0, "", "")
+ login.sessionChannel <- &loginAttempt{session, loginError}
+ }
case Password:
// Even if the login is supposed to be without two-factor-authentication, we
// attempt parsing a 2fa code, since the underlying rest-call can also handle

Remove unnecessary dummy lookup for validatin the session when
logging in using email and password