def check_user_existed_or_signup(user_info):
try:
return_msg = {}
with UserDao() as userDao:
is_existed = userDao.checkUserExisted(userName=user_info['user_name'])
if is_existed:
return_msg['flash'] = 'The name "{name}" has been used'.format(name=user_info['user_name'])
return return_msg
hashed_passwd = bcrypt.hashpw(user_info['user_password'].encode('utf-8'),bcrypt.gensalt())
with UserDao() as userdao:
userdao.createNewUser(userName=user_info['user_name'],userPassword=hashed_passwd)
return_msg['flash'] = 'User "{name}" create success!'.format(name=user_info['user_name'])
return return_msg
except:
return_msg["error"] = "Fail to check whether user is existed or create new user"
return return_msg
#
评论列表
文章目录