user.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package api
  2. import "github.com/lejianwen/rustdesk-api/model"
  3. /*
  4. pub enum UserStatus {
  5. Disabled = 0,
  6. Normal = 1,
  7. Unverified = -1,
  8. }
  9. */
  10. /*
  11. UserPayload
  12. String name = ”;
  13. String email = ”;
  14. String note = ”;
  15. UserStatus status;
  16. bool isAdmin = false;
  17. */
  18. type UserPayload struct {
  19. Name string `json:"name"`
  20. Email string `json:"email"`
  21. Note string `json:"note"`
  22. IsAdmin *bool `json:"is_admin"`
  23. Status int `json:"status"`
  24. Info map[string]interface{} `json:"info"`
  25. }
  26. func (up *UserPayload) FromUser(user *model.User) *UserPayload {
  27. up.Name = user.Username
  28. up.Email = user.Email
  29. up.IsAdmin = user.IsAdmin
  30. up.Status = int(user.Status)
  31. up.Info = map[string]interface{}{}
  32. return up
  33. }
  34. /*
  35. class HttpType {
  36. static const kAuthReqTypeAccount = "account";
  37. static const kAuthReqTypeMobile = "mobile";
  38. static const kAuthReqTypeSMSCode = "sms_code";
  39. static const kAuthReqTypeEmailCode = "email_code";
  40. static const kAuthReqTypeTfaCode = "tfa_code";
  41. static const kAuthResTypeToken = "access_token";
  42. static const kAuthResTypeEmailCheck = "email_check";
  43. static const kAuthResTypeTfaCheck = "tfa_check";
  44. }
  45. */
  46. type LoginRes struct {
  47. Type string `json:"type"`
  48. AccessToken string `json:"access_token"`
  49. User UserPayload `json:"user"`
  50. Secret string `json:"secret,omitempty"`
  51. TfaType string `json:"tfa_type,omitempty"`
  52. }