2020-11-11 22:48:11 +00:00
|
|
|
package modweb
|
|
|
|
|
2020-11-16 20:19:37 +00:00
|
|
|
import "github.com/gofiber/session/v2"
|
|
|
|
|
2020-11-11 22:48:11 +00:00
|
|
|
type AuthHandler interface {
|
2020-11-16 20:19:37 +00:00
|
|
|
Module
|
|
|
|
LoginURL() string
|
|
|
|
RegisterURL() string
|
|
|
|
}
|
|
|
|
|
|
|
|
type User struct {
|
|
|
|
ID string
|
|
|
|
DisplayName string
|
|
|
|
AccessLevel int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u User) Save(store *session.Store) {
|
|
|
|
store.Set("user:id", u.ID)
|
|
|
|
store.Set("user:displayName", u.DisplayName)
|
|
|
|
store.Set("user:accessLevel", u.AccessLevel)
|
|
|
|
}
|
2020-11-11 22:48:11 +00:00
|
|
|
|
2020-11-16 20:19:37 +00:00
|
|
|
func (u *User) Load(store *session.Store) {
|
|
|
|
u.ID = store.Get("user:id").(string)
|
|
|
|
u.DisplayName = store.Get("user:displayName").(string)
|
|
|
|
u.AccessLevel = store.Get("user:accessLevel").(int64)
|
2020-11-11 22:48:11 +00:00
|
|
|
}
|