Core functionality for new aiterp.net servers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
825 B

package auth
// User represents a logged-in user of the website or app.
type User struct {
ID string `json:"id"`
Level string `json:"level"`
Data map[string]string `json:"data"`
Session *Session `json:"-"`
method Authenticator
loggedOut bool
}
// FullID is the userid prefixed with the method ID
func (user *User) FullID() string {
return user.method.ID() + ":" + user.ID
}
// Logout flags the user for logout
func (user *User) Logout() {
user.loggedOut = true
}
// LoggedOut returns whether the Logout() function has been called
func (user *User) LoggedOut() bool {
return user.loggedOut
}
// NewUser creates a new User object
func NewUser(method Authenticator, id, level string, data map[string]string) *User {
return &User{id, level, data, nil, method, false}
}