mirror of
https://github.com/mrusme/neonmodem.git
synced 2025-06-30 22:18:39 -04:00
Add support for fetching password from keyring for lemmy
This commit is contained in:
parent
7e5a4835f8
commit
d7b2cb7303
@ -62,6 +62,8 @@ func (sys *System) Connect(sysURL string) error {
|
||||
} else {
|
||||
credentials["password"] = password
|
||||
}
|
||||
} else {
|
||||
credentials["password"] = "password_in_keyring"
|
||||
}
|
||||
|
||||
if sys.config == nil {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
"github.com/mrusme/neonmodem/models/author"
|
||||
"github.com/mrusme/neonmodem/models/forum"
|
||||
"github.com/mrusme/neonmodem/models/post"
|
||||
@ -144,9 +145,25 @@ func (sys *System) Load() error {
|
||||
credentials[k] = v.(string)
|
||||
}
|
||||
|
||||
ring, _ := keyring.Open(keyring.Config{
|
||||
ServiceName: "NeonModem - Lemmy",
|
||||
})
|
||||
|
||||
var password string
|
||||
|
||||
if credentials["password"] == "password_in_keyring" {
|
||||
p, err := ring.Get("password")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
password = string(p.Data)
|
||||
} else {
|
||||
password = credentials["password"]
|
||||
}
|
||||
|
||||
err = sys.client.ClientLogin(context.Background(), types.Login{
|
||||
UsernameOrEmail: credentials["username"],
|
||||
Password: credentials["password"],
|
||||
Password: password,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user