Store token after first login to keyring (#5)

This commit is contained in:
rigormorrtiss 2021-07-20 14:47:32 +04:00 • committed by GitHub
parent aaf881bf06
commit 760b29fa29
2 changed files with 3 additions and 14 deletions

View file

@ -35,16 +35,8 @@ func main() {
mainFlex = ui.NewMainFlex(guildsDropDown, channelsList, messagesTextView)
app = ui.NewApplication(onApplicationInputCapture)
email := util.GetPassword("email")
password := util.GetPassword("password")
token := util.GetPassword("token")
if email != "" && password != "" {
app.
SetRoot(mainFlex, true).
SetFocus(guildsDropDown)
discordSession = newSession(email, password, "")
} else if token != "" {
if token != "" {
app.
SetRoot(mainFlex, true).
SetFocus(guildsDropDown)
@ -215,9 +207,7 @@ func onLoginFormLoginButtonSelected() {
}
discordSession = newSession(email, password, "")
util.SetPassword("email", email)
util.SetPassword("password", password)
util.SetPassword("token", discordSession.Token)
} else if loginVia == "token" {
token := loginForm.GetFormItemByLabel("Token").(*tview.InputField).GetText()
if token == "" {
@ -225,7 +215,6 @@ func onLoginFormLoginButtonSelected() {
}
discordSession = newSession("", "", token)
util.SetPassword("token", token)
}

View file

@ -16,7 +16,7 @@ func NewLoginForm(via string, onLoginFormLoginButtonSelected func(), onLoginForm
SetButtonBackgroundColor(loginFormButtonBackgroundColor).
SetBackgroundColor(loginFormBackgroundColor).
SetBorder(true).
SetBorderPadding(15, 15, 15, 15)
SetBorderPadding(0, 0, 1, 1)
if via == "token" {
loginForm.AddPasswordField("Token", "", 0, 0, nil)