def wxlogin(): form = WxLoginForm().validate_for_api() code = form.code.data res = request_wx_api(code) user = manager.find_user(openid=res['openid']) if user: raise ParameterException(msg='邮箱已被注册,请重新输入邮箱') wx_register_user(res) return 'success'
def register(): form = RegisterForm().validate_for_api() user = manager.find_user(nickname=form.nickname.data) if user: raise RepeatException(msg='用户名重复,请重新输入') if form.email.data and form.email.data.strip() != "": user = manager.user_model.query.filter(and_(manager.user_model.email.isnot(None), manager.user_model.email == form.email.data)).first() if user: raise RepeatException(msg='注册邮箱重复,请重新输入') _register_user(form) return Success(msg='用户创建成功')