constants.js 1.9 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
const db = uniCloud.database()
const dbCmd = db.command
const userCollectionName = 'uni-id-users'
const userCollection = db.collection(userCollectionName)
const verifyCollectionName = 'opendb-verify-codes'
const verifyCollection = db.collection(verifyCollectionName)
const deviceCollectionName = 'uni-id-device'
const deviceCollection = db.collection(deviceCollectionName)

const USER_IDENTIFIER = {
  username: 'username',
  mobile: 'mobile',
  email: 'email',
  wx_unionid: 'wechat-account',
  'wx_openid.app': 'wechat-account',
雪洛's avatar
雪洛 已提交
16 17 18
  'wx_openid.mp': 'wechat-account',
  'wx_openid.h5': 'wechat-account',
  'wx_openid.web': 'wechat-account',
DCloud_JSON's avatar
DCloud_JSON 已提交
19 20
  qq_unionid: 'qq-account',
  'qq_openid.app': 'qq-account',
雪洛's avatar
雪洛 已提交
21
  'qq_openid.mp': 'qq-account',
DCloud_JSON's avatar
DCloud_JSON 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34
  ali_openid: 'alipay-account',
  apple_openid: 'alipay-account'
}

const USER_STATUS = {
  NORMAL: 0,
  BANNED: 1,
  AUDITING: 2,
  AUDIT_FAILED: 3,
  CLOSED: 4
}

const CAPTCHA_SCENE = {
雪洛's avatar
雪洛 已提交
35
  REGISTER: 'register',
DCloud_JSON's avatar
DCloud_JSON 已提交
36 37 38
  LOGIN_BY_PWD: 'login-by-pwd',
  LOGIN_BY_SMS: 'login-by-sms',
  RESET_PWD_BY_SMS: 'reset-pwd-by-sms',
39
  RESET_PWD_BY_EMAIL: 'reset-pwd-by-email',
DCloud_JSON's avatar
DCloud_JSON 已提交
40
  SEND_SMS_CODE: 'send-sms-code',
41
  SEND_EMAIL_CODE: 'send-email-code',
DCloud_JSON's avatar
DCloud_JSON 已提交
42 43 44 45 46 47 48 49
  BIND_MOBILE_BY_SMS: 'bind-mobile-by-sms'
}

const LOG_TYPE = {
  LOGOUT: 'logout',
  LOGIN: 'login',
  REGISTER: 'register',
  RESET_PWD_BY_SMS: 'reset-pwd',
50
  RESET_PWD_BY_EMAIL: 'reset-pwd',
DCloud_JSON's avatar
DCloud_JSON 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63
  BIND_MOBILE: 'bind-mobile',
  BIND_WEIXIN: 'bind-weixin',
  BIND_QQ: 'bind-qq',
  BIND_APPLE: 'bind-apple',
  BIND_ALIPAY: 'bind-alipay'
}

const SMS_SCENE = {
  LOGIN_BY_SMS: 'login-by-sms',
  RESET_PWD_BY_SMS: 'reset-pwd-by-sms',
  BIND_MOBILE_BY_SMS: 'bind-mobile-by-sms'
}

64 65 66 67 68 69 70
const EMAIL_SCENE = {
  REGISTER: 'register',
  LOGIN_BY_EMAIL: 'login-by-email',
  RESET_PWD_BY_EMAIL: 'reset-pwd-by-email',
  BIND_EMAIL: 'bind-email'
}

DCloud_JSON's avatar
DCloud_JSON 已提交
71 72 73 74 75 76 77 78 79 80
module.exports = {
  db,
  dbCmd,
  userCollection,
  verifyCollection,
  deviceCollection,
  USER_IDENTIFIER,
  USER_STATUS,
  CAPTCHA_SCENE,
  LOG_TYPE,
81 82
  SMS_SCENE,
  EMAIL_SCENE
DCloud_JSON's avatar
DCloud_JSON 已提交
83
}