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

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. package auth
  2. // User represents a logged-in user of the website or app.
  3. type User struct {
  4. ID string `json:"id"`
  5. Level string `json:"level"`
  6. Data map[string]string `json:"data"`
  7. Session *Session `json:"-"`
  8. method Authenticator
  9. loggedOut bool
  10. }
  11. // FullID is the userid prefixed with the method ID
  12. func (user *User) FullID() string {
  13. return user.method.ID() + ":" + user.ID
  14. }
  15. // Logout flags the user for logout
  16. func (user *User) Logout() {
  17. user.loggedOut = true
  18. }
  19. // LoggedOut returns whether the Logout() function has been called
  20. func (user *User) LoggedOut() bool {
  21. return user.loggedOut
  22. }
  23. // NewUser creates a new User object
  24. func NewUser(method Authenticator, id, level string, data map[string]string) *User {
  25. return &User{id, level, data, nil, method, false}
  26. }