common.go 478 B

123456789101112131415161718192021222324252627282930313233343536
  1. package accounts
  2. type User struct {
  3. Username string
  4. IsAdmin bool
  5. }
  6. func (u User) IsEmpty() bool {
  7. return u.Username == ""
  8. }
  9. type AuthenticationSource int
  10. const (
  11. Header AuthenticationSource = iota
  12. Cookie
  13. )
  14. type Authentication struct {
  15. Token string
  16. Source AuthenticationSource
  17. CsrfToken string
  18. }
  19. type AuthError struct {
  20. Err error
  21. }
  22. func (e AuthError) Error() string {
  23. return "Auth error: " + e.Err.Error()
  24. }
  25. func (e AuthError) Unwrap() error {
  26. return e.Err
  27. }