def create_user(post_data): out_dic = {'success': False, 'code': '00'} if tools.check_username_valid(post_data['user_name']): pass else: out_dic['code'] = '11' return out_dic if tools.check_email_valid(post_data['user_email']): pass else: out_dic['code'] = '21' return out_dic if 'role' in post_data: role = post_data['role'] else: role = '1000' TabMember.create(uid=tools.get_uuid(), user_name=post_data['user_name'], user_pass=tools.md5(post_data['user_pass']), user_email=post_data['user_email'], role=role, time_create=tools.timestamp(), time_update=tools.timestamp(), time_reset_passwd=tools.timestamp(), time_login=tools.timestamp(), time_email=tools.timestamp()) out_dic['success'] = True return out_dic
def create_user(post_data): ''' Create the user. The code used if `False`. 11: standsfor invalid username. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' out_dic = {'success': False, 'code': '00'} if not tools.check_username_valid(post_data['user_name']): out_dic['code'] = '11' return out_dic if not tools.check_email_valid(post_data['user_email']): out_dic['code'] = '21' return out_dic try: TabMember.create(uid=tools.get_uuid(), user_name=post_data['user_name'], user_pass=tools.md5(post_data['user_pass']), user_email=post_data['user_email'], role=post_data.get('role', '1000'), time_create=tools.timestamp(), time_update=tools.timestamp(), time_reset_passwd=tools.timestamp(), time_login=tools.timestamp(), time_email=tools.timestamp()) out_dic['success'] = True except: out_dic['code'] = '91' return out_dic
def create_user(post_data, extinfo=None): ''' Create the user. The code used if `False`. 11: invalid username. 21: invalide E-mail. 31: E-mail exists.. 91: unkown reason. ''' out_dic = {'success': False, 'code': '00'} if post_data['user_name'].startswith('_'): ''' the user_name startwith with ``_``, ONLY used for inner, not for login. ''' pass elif not tools.check_username_valid(post_data['user_name']): out_dic['code'] = '11' return out_dic if not tools.check_email_valid(post_data['user_email']): out_dic['code'] = '21' return out_dic if MUser.get_by_email(post_data['user_email']): out_dic['code'] = '31' return out_dic if extinfo is None: extinfo = {} try: TabMember.create( uid=tools.get_uuid(), user_name=post_data['user_name'], user_pass=tools.md5(post_data['user_pass']), user_email=post_data['user_email'], role='1000', # ‘1000' as default role. time_create=tools.timestamp(), time_update=tools.timestamp(), time_reset_passwd=tools.timestamp(), time_login=tools.timestamp(), time_email=tools.timestamp(), extinfo=extinfo, ) out_dic['success'] = True except Exception as err: print(repr(err)) out_dic['code'] = '91' return out_dic
def create_user(post_data): ''' Create the user. The code used if `False`. 11: standsfor invalid username. 21: standsfor invalide E-mail. 91: standsfor unkown reson. ''' out_dic = {'success': False, 'code': '00'} if post_data['user_name'].startswith('_'): ''' the user_name startwith with ``_``, ONLY used for inner, not for login. ''' pass elif not tools.check_username_valid(post_data['user_name']): out_dic['code'] = '11' return out_dic if not tools.check_email_valid(post_data['user_email']): out_dic['code'] = '21' return out_dic try: TabMember.create( uid=tools.get_uuid(), user_name=post_data['user_name'], user_pass=tools.md5(post_data['user_pass']), user_email=post_data['user_email'], role='1000', # ‘1000' as default role. time_create=tools.timestamp(), time_update=tools.timestamp(), time_reset_passwd=tools.timestamp(), time_login=tools.timestamp(), time_email=tools.timestamp()) out_dic['success'] = True except: out_dic['code'] = '91' return out_dic