modweb/auth.go

27 lines
579 B
Go

package modweb
import "github.com/gofiber/session/v2"
type AuthHandler interface {
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)
}
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)
}