コード例 #1
0
ファイル: auth.py プロジェクト: limingjin10/flask-reptiles
def register():
    form = RegisterForm().validate_for_api()
    if request.method == 'POST' and form.validate():
        # 判断code是否正确
        key = "note:email:{}".format(form.email.data)
        if redis_client.get(key) and int(
                redis_client.get(key)) != form.code.data:
            raise ParameterException(msg='code码不正确,要重新获取喽', error_code=1012)
        with db.auto_commit():
            user = User()
            user.set_attrs(form.data)
            db.session.add(user)
    return Success()
コード例 #2
0
ファイル: user.py プロジェクト: wlf36/lin-cms-flask
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='用户创建成功')
コード例 #3
0
def register_user_api():
    form = RegisterForm().validate_for_api().data_
    _verification(form['uuid'])
    User.register(form['username'], form['password'])
    return CreateSuccess('register successful')