user.go 867 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package models
  2. import (
  3. "gorm.io/gorm"
  4. )
  5. // User type that extends gorm.Model
  6. type User struct {
  7. gorm.Model
  8. Email string `json:"email" gorm:"unique"`
  9. Password string `json:"password"`
  10. EmailVerified bool `json:"email_verified"`
  11. // ID of oauth integration for github connection (optional)
  12. GithubAppIntegrationID uint
  13. // The github user id used for login (optional)
  14. GithubUserID int64
  15. GoogleUserID string
  16. }
  17. // UserExternal represents the User type that is sent over REST
  18. type UserExternal struct {
  19. ID uint `json:"id"`
  20. Email string `json:"email"`
  21. EmailVerified bool `json:"email_verified"`
  22. }
  23. // Externalize generates an external User to be shared over REST
  24. func (u *User) Externalize() *UserExternal {
  25. return &UserExternal{
  26. ID: u.ID,
  27. Email: u.Email,
  28. EmailVerified: u.EmailVerified,
  29. }
  30. }