Ejemplo n.º 1
0
 def register(self, params):
     userData = Users().getOne({Users.email == params['email']})
     if (userData == None):
         #昵称首字母
         isChinese = re.compile(u"[\u4e00-\u9fa5]+")
         isEnglish = re.compile('[a-zA-Z]')
         nickNameFirstWord = params['nickName'][0]
         if isChinese.search(nickNameFirstWord):
             first_word = Pinyin().get_initial(nickNameFirstWord)
         elif isEnglish.search(nickNameFirstWord):
             first_word = nickNameFirstWord.upper()
         else:
             first_word = '#'
         data = {
             'email': params['email'],
             'password': Users.set_password(params['password']),
             'nick_name': params['nickName'],
             'head_img': params['headImg'],
             'first_word': first_word,
             'created_at': time.time(),
             'updated_at': time.time()
         }
         user = Users().add(data)
         if user == False:
             return Utils.formatError(Code.BAD_REQUEST, '注册失败')
         else:
             result = UsersAuthJWT.authenticate(params['email'],
                                                params['password'])
             return result
         return Utils.formatError(Code.BAD_REQUEST, '注册失败')
     return Utils.formatError(Code.BAD_REQUEST, '账号已注册')
Ejemplo n.º 2
0
def register(params):
    ''' 注册 '''
    filters = {Users.email == params['email']}
    userData = Users().getOne(filters)
    if (userData == None):
        user = Users(email=params['email'],
                     password=Users.set_password(params['password']),
                     status=1)
        status = user.add(user)
        if status == True:
            return BaseController().successData(msg='注册成功')
        return BaseController().error('注册失败')
    return BaseController().error('账号已注册')
Ejemplo n.º 3
0
 def register(params):
     userData = Users().getOne({Users.email == params['email']})
     if (userData == None):
         #昵称首字母
         isChinese = re.compile(u"[\u4e00-\u9fa5]+")
         isEnglish = re.compile('[a-zA-Z]')
         nickNameFirstWord = params['nickName'][0]
         nowTime = time.time()
         if isChinese.search(nickNameFirstWord):
             first_word = Pinyin().get_initial(nickNameFirstWord)
         elif isEnglish.search(nickNameFirstWord):
             first_word = nickNameFirstWord.upper()
         else:
             first_word = '#'
         data = {
             'email': params['email'],
             'password': Users.set_password(params['password']),
             'nick_name': params['nickName'],
             'head_img': params['headImg'],
             'first_word': first_word,
             'created_at': nowTime,
             'updated_at': nowTime
         }
         user = Users().add(data)
         if user == False:
             return Utils.formatError(CONST['CODE']['BAD_REQUEST']['value'],
                                      '注册失败')
         else:
             result = UsersAuthJWT.authenticate(params['email'],
                                                params['password'])
             # 发送延时推广进群广告
             invite = Invite()
             invite.setAction("invite")
             invite.setId(result['data']['user']['id'])
             # 延时2分钟推送
             delayQueue.product(invite.__dict__, 120)
             return result
     return Utils.formatError(CONST['CODE']['BAD_REQUEST']['value'],
                              '账号已注册')