mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2026-10-20 08:16:40 +00:00
If using this plugin as a source for multiple auth, the user creation wizard would overwridde other data it should not have as the base assumption when we wrote this is the plugin own the config but if that assumption get removed (like when we tried to user multiple auth in the same time), it would catrastrophically fail
40 lines
777 B
Go
40 lines
777 B
Go
package plg_authenticate_local
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type pluginConfig map[string]any
|
|
|
|
func (this pluginConfig) GetUsers() ([]User, error) {
|
|
db, ok := this["db"].(string)
|
|
if !ok || db == "" {
|
|
return []User{}, nil
|
|
}
|
|
var users []User
|
|
if err := json.Unmarshal([]byte(db), &users); err != nil {
|
|
return nil, err
|
|
}
|
|
return users, nil
|
|
}
|
|
|
|
func (this pluginConfig) GetMailSubject() string {
|
|
if subject, ok := this["notification_subject"].(string); ok {
|
|
return subject
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (this pluginConfig) GetMailBody() string {
|
|
if body, ok := this["notification_body"].(string); ok {
|
|
return body
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func (this pluginConfig) SetUsers(users []User) {
|
|
if usersData, err := json.Marshal(users); err == nil {
|
|
this["db"] = string(usersData)
|
|
}
|
|
}
|