0
0
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:
tedwardd 2023-06-16 15:06:00 -04:00
parent 7e5a4835f8
commit d7b2cb7303
2 changed files with 20 additions and 1 deletions

View File

@ -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 {

View File

@ -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