refactor: remove keyring utility
This commit is contained in:
parent
4bd98d596d
commit
102a45b66a
2 changed files with 4 additions and 23 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/rigormorrtiss/discordo/ui"
|
||||
"github.com/rigormorrtiss/discordo/util"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -45,7 +46,7 @@ func main() {
|
|||
)
|
||||
|
||||
token := config.Token
|
||||
if t := util.GetPassword("token"); t != "" {
|
||||
if t, _ := keyring.Get("discordo", "token"); t != "" {
|
||||
token = t
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +253,7 @@ func onLoginFormLoginButtonSelected() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
go util.SetPassword("token", lr.Token)
|
||||
go keyring.Set("discordo", "token", lr.Token)
|
||||
} else if lr.MFA {
|
||||
loginForm = ui.NewMfaLoginForm(func() {
|
||||
code := loginForm.GetFormItem(0).(*tview.InputField).GetText()
|
||||
|
|
@ -275,7 +276,7 @@ func onLoginFormLoginButtonSelected() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
go util.SetPassword("token", lr.Token)
|
||||
go keyring.Set("discordo", "token", lr.Token)
|
||||
})
|
||||
|
||||
app.SetRoot(loginForm, true)
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package util
|
||||
|
||||
import "github.com/zalando/go-keyring"
|
||||
|
||||
// GetPassword retrieves the password in keyring for provided user.
|
||||
func GetPassword(u string) string {
|
||||
p, err := keyring.Get("discordo", u)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// SetPassword sets the password in keyring for provided user.
|
||||
func SetPassword(u string, p string) {
|
||||
if err := keyring.Set("discordo", u, p); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue