Add support for mail / password login including 2fa support.
MODIFY
app/app.go
app/app.go
@@ -15,8 +15,7 @@ import (
)
const (
- userSession = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"
- defaultLoginMessage = "\nPlease input your token. Prepend 'Bot ' for bot tokens.\n\nFor information on how to retrieve your token, check:\nhttps://github.com/Bios-Marcel/cordless/wiki/Retrieving-your-token\n\nToken input is hidden by default, toggle with Ctrl + R."
+ userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"
)
var suspended = false
@@ -63,7 +62,7 @@ func Run() {
panic(shortcutsLoadError)
}
- discord := attemptLogin(loginScreen, defaultLoginMessage, app, configuration)
+ discord := attemptLogin(loginScreen, "", configuration)
config.GetConfig().Token = discord.Token
@@ -167,33 +166,28 @@ func Run() {
}
}
-func attemptLogin(loginScreen *ui.Login, loginMessage string, app *tview.Application, configuration *config.Config) *discordgo.Session {
+func attemptLogin(loginScreen *ui.Login, loginMessage string, configuration *config.Config) *discordgo.Session {
var (
session *discordgo.Session
discordError error
)
if configuration.Token == "" {
- token := loginScreen.RequestToken(loginMessage)
- session, discordError = discordgo.NewWithToken(
- userSession,
- token)
+ session, discordError = loginScreen.RequestLogin(loginMessage)
} else {
- session, discordError = discordgo.NewWithToken(
- userSession,
- configuration.Token)
+ session, discordError = discordgo.NewWithToken(userAgent, configuration.Token)
}
if discordError != nil {
configuration.Token = ""
- return attemptLogin(loginScreen, fmt.Sprintf("Error during last login attempt:\n\n[red]%s\n\n%s", discordError, defaultLoginMessage), app, configuration)
+ 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 {
configuration.Token = ""
- return attemptLogin(loginScreen, fmt.Sprintf("Error during last login attempt:\n\n[red]%s\n\n%s", discordError, defaultLoginMessage), app, configuration)
+ return attemptLogin(loginScreen, fmt.Sprintf("Error during last login attempt:\n\n[red]%s", discordError), configuration)
}
return session

MODIFY
go.mod
go.mod
@@ -4,7 +4,7 @@ go 1.12
require (
github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912
- github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14
+ github.com/Bios-Marcel/discordgo v0.20.4-0.20191101185414-2d27b68262e6
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d
github.com/Bios-Marcel/shortnotforlong v1.0.0
github.com/Bios-Marcel/tview v0.0.0-20191024171520-41147a2f8cf9

MODIFY
go.sum
go.sum
@@ -2,6 +2,8 @@ github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912 h1:Qxa
github.com/Bios-Marcel/discordemojimap v0.0.0-20190404160132-506fd0e8d912/go.mod h1:D1W9gRQXP1UESEobmNIng2i+E8UvdDF4NJ9EOXn9Ano=
github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14 h1:rMm2kL+lOb4eYdDexAsFV8dlEX+0V/Jkr05SZQpZ83E=
github.com/Bios-Marcel/discordgo v0.20.4-0.20191012193840-26cddf403c14/go.mod h1:bLnfQU0j/SejmPozgW5GepmKvd8CrbMIml2I0IZENVE=
+github.com/Bios-Marcel/discordgo v0.20.4-0.20191101185414-2d27b68262e6 h1:Ed7t7xaw30EJqu6jqpAwHBjjq3A+de5+7qUwEkzcfd0=
+github.com/Bios-Marcel/discordgo v0.20.4-0.20191101185414-2d27b68262e6/go.mod h1:bLnfQU0j/SejmPozgW5GepmKvd8CrbMIml2I0IZENVE=
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d h1:vfrX8l3fHuaP7gRgEc7mX/lHVTlfQcQeaIdSPmT6Ej0=
github.com/Bios-Marcel/goclipimg v0.0.0-20190417192721-b58a8831f27d/go.mod h1:u7z9t086HoIbA/uuoA2KcRDhKS47DRYCDZ39aegTR4c=
github.com/Bios-Marcel/shortnotforlong v1.0.0 h1:K4JJ5U3+D8LXoAiH0QbfMujWuqKo+NAEZKuQ2RHPqqE=

Add support for mail / password login including 2fa support.