Create constant for keyring Service (discordo) (#49)
This commit is contained in:
parent
f945fbf4f8
commit
746909a309
1 changed files with 7 additions and 4 deletions
11
main.go
11
main.go
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"github.com/zalando/go-keyring"
|
"github.com/zalando/go-keyring"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const Service = "discordo"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
app *tview.Application
|
app *tview.Application
|
||||||
loginForm *tview.Form
|
loginForm *tview.Form
|
||||||
|
|
@ -15,7 +17,8 @@ var (
|
||||||
messageInputField *tview.InputField
|
messageInputField *tview.InputField
|
||||||
mainFlex *tview.Flex
|
mainFlex *tview.Flex
|
||||||
|
|
||||||
conf *config
|
conf *config
|
||||||
|
|
||||||
session *discordgo.Session
|
session *discordgo.Session
|
||||||
selectedChannel *discordgo.Channel
|
selectedChannel *discordgo.Channel
|
||||||
selectedMessage *discordgo.Message
|
selectedMessage *discordgo.Message
|
||||||
|
|
@ -43,7 +46,7 @@ func main() {
|
||||||
AddItem(rightFlex, 0, 4, false)
|
AddItem(rightFlex, 0, 4, false)
|
||||||
|
|
||||||
token := conf.Token
|
token := conf.Token
|
||||||
if t, _ := keyring.Get("discordo", "token"); t != "" {
|
if t, _ := keyring.Get(Service, "token"); t != "" {
|
||||||
token = t
|
token = t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +111,7 @@ func onLoginFormLoginButtonSelected() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go keyring.Set("discordo", "token", lr.Token)
|
go keyring.Set(Service, "token", lr.Token)
|
||||||
} else if lr.MFA {
|
} else if lr.MFA {
|
||||||
// The account has MFA enabled, reattempt login with code and ticket.
|
// The account has MFA enabled, reattempt login with code and ticket.
|
||||||
loginForm = newLoginForm(func() {
|
loginForm = newLoginForm(func() {
|
||||||
|
|
@ -132,7 +135,7 @@ func onLoginFormLoginButtonSelected() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go keyring.Set("discordo", "token", lr.Token)
|
go keyring.Set(Service, "token", lr.Token)
|
||||||
}, true)
|
}, true)
|
||||||
|
|
||||||
app.SetRoot(loginForm, true)
|
app.SetRoot(loginForm, true)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue