2
0

user.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. FirstName string `json:"first_name"`
  13. LastName string `json:"last_name"`
  14. CompanyName string `json:"company_name"`
  15. // ID of oauth integration for github connection (optional)
  16. GithubAppIntegrationID uint
  17. // The github user id used for login (optional)
  18. GithubUserID int64
  19. GoogleUserID string
  20. AuthProvider string `json:"auth_provider"`
  21. ExternalId string `json:"external_id"`
  22. }
  23. // AuthProvider_Ory represents the Ory auth provider
  24. const AuthProvider_Ory = "ory"
  25. // ToUserType generates an external types.User to be shared over REST
  26. func (u *User) ToUserType() *types.User {
  27. return &types.User{
  28. ID: u.ID,
  29. Email: u.Email,
  30. EmailVerified: u.EmailVerified,
  31. FirstName: u.FirstName,
  32. LastName: u.LastName,
  33. CompanyName: u.CompanyName,
  34. }
  35. }