Exemplo n.º 1
0
 def post(self):
     uid_mct = self.get_current_user().get('Fid')
     pms = self.check_arg('permission', u'^[\d\w,]{1,512}$', '')
     kwargs = {
         'Fuser_mobi':
         self.check_arg('user_mobi', u'^\d{1,28}$'),
         'Fuser_name':
         self.check_arg('user_name', u'^[\u4e00-\u9fa5\d\w\s]{1,28}$'),
         'Fuser_pwd':
         self.check_arg('user_pwd', u'^[\d\w]{1,28}$'),
         'Femail':
         self.check_arg('user_email', u'^[\w\d@.]{1,64}$', ''),
         'Fcompany_id':
         self.get_current_user().get('Fcompany_id'),
         "Fpermission":
         pms
     }
     pwd_srv = UserServices(self.db)
     user_srv = CompanyUserServices(self.db)
     user = pwd_srv.query_user_by_phone(
         self.get_argument('user_mobi').strip())
     if user:
         if pwd_srv.query_company_user(uid_mct, user.Fid):
             return self.write(
                 ujson.dumps({
                     'stat': 'error',
                     'msg': '账号已存在!'
                 }))
         else:
             data = {}
             data['Fpermission'] = kwargs.get('Fpermission')
             pwd_srv.update_user(user.Fid, **data)
     else:
         kwargs['Fuid'] = pwd_srv.user_uid(phone=kwargs['Fuser_mobi'],
                                           email=kwargs['Femail'])
         kwargs['Fuser_pwd'] = pwd_srv.user_passed(kwargs['Fuser_pwd'],
                                                   kwargs['Fuid'])
         user = user_srv.add_users(**kwargs)
     user_srv.add_company_user(user, uid_mct, **kwargs)
     return self.write(ujson.dumps({'stat': 'ok', 'msg': ''}))
Exemplo n.º 2
0
    def post(self):
        res = self.check_args(
            Fbirthday='',
            Femail='',
            Fweixin='',
            Fweibo='',
            Fqq='',
            Fuser_pwd='',
        )
        if res:
            return self.write(Error(2000, res, "参数错误").__dict__)

        Fid = self.get_current_user().get('Fid')
        self.get_paras_dict()
        del self.qdict['_xsrf']
        user_srv = UserServices(self.db)
        if self.qdict['Fuser_pwd']:
            _user = user_srv.get_user_by_id(Fid)
            self.qdict['Fuser_pwd'] = user_srv.user_passed(
                self.qdict['Fuser_pwd'],
                _user.Fuid)
        user_srv.update_user(Fid, **self.qdict)
        return self.write({'stat': 'ok', 'msg': ''})