Files
MickaelK 4595b6a8d2 fix (plg_authenticate_local): better configuration
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
2025-12-22 15:24:59 +11:00

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)
}
}