2
0

user.go 1.1 KB

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