constants.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const db = uniCloud.database()
  2. const dbCmd = db.command
  3. const userCollectionName = 'uni-id-users'
  4. const userCollection = db.collection(userCollectionName)
  5. const verifyCollectionName = 'opendb-verify-codes'
  6. const verifyCollection = db.collection(verifyCollectionName)
  7. const deviceCollectionName = 'uni-id-device'
  8. const deviceCollection = db.collection(deviceCollectionName)
  9. const USER_IDENTIFIER = {
  10. username: 'username',
  11. mobile: 'mobile',
  12. email: 'email',
  13. wx_unionid: 'wechat-account',
  14. 'wx_openid.app': 'wechat-account',
  15. 'wx_openid.mp': 'wechat-account',
  16. 'wx_openid.h5': 'wechat-account',
  17. 'wx_openid.web': 'wechat-account',
  18. qq_unionid: 'qq-account',
  19. 'qq_openid.app': 'qq-account',
  20. 'qq_openid.mp': 'qq-account',
  21. ali_openid: 'alipay-account',
  22. apple_openid: 'alipay-account'
  23. }
  24. const USER_STATUS = {
  25. NORMAL: 0,
  26. BANNED: 1,
  27. AUDITING: 2,
  28. AUDIT_FAILED: 3,
  29. CLOSED: 4
  30. }
  31. const CAPTCHA_SCENE = {
  32. REGISTER: 'register',
  33. LOGIN_BY_PWD: 'login-by-pwd',
  34. LOGIN_BY_SMS: 'login-by-sms',
  35. RESET_PWD_BY_SMS: 'reset-pwd-by-sms',
  36. RESET_PWD_BY_EMAIL: 'reset-pwd-by-email',
  37. SEND_SMS_CODE: 'send-sms-code',
  38. SEND_EMAIL_CODE: 'send-email-code',
  39. BIND_MOBILE_BY_SMS: 'bind-mobile-by-sms'
  40. }
  41. const LOG_TYPE = {
  42. LOGOUT: 'logout',
  43. LOGIN: 'login',
  44. REGISTER: 'register',
  45. RESET_PWD_BY_SMS: 'reset-pwd',
  46. RESET_PWD_BY_EMAIL: 'reset-pwd',
  47. BIND_MOBILE: 'bind-mobile',
  48. BIND_WEIXIN: 'bind-weixin',
  49. BIND_QQ: 'bind-qq',
  50. BIND_APPLE: 'bind-apple',
  51. BIND_ALIPAY: 'bind-alipay'
  52. }
  53. const SMS_SCENE = {
  54. LOGIN_BY_SMS: 'login-by-sms',
  55. RESET_PWD_BY_SMS: 'reset-pwd-by-sms',
  56. BIND_MOBILE_BY_SMS: 'bind-mobile-by-sms'
  57. }
  58. const EMAIL_SCENE = {
  59. REGISTER: 'register',
  60. LOGIN_BY_EMAIL: 'login-by-email',
  61. RESET_PWD_BY_EMAIL: 'reset-pwd-by-email',
  62. BIND_EMAIL: 'bind-email'
  63. }
  64. module.exports = {
  65. db,
  66. dbCmd,
  67. userCollection,
  68. verifyCollection,
  69. deviceCollection,
  70. USER_IDENTIFIER,
  71. USER_STATUS,
  72. CAPTCHA_SCENE,
  73. LOG_TYPE,
  74. SMS_SCENE,
  75. EMAIL_SCENE
  76. }