当前位置: 首页>>代码示例>>Python>>正文


Python User.new_user方法代码示例

本文整理汇总了Python中user.User.new_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.new_user方法的具体用法?Python User.new_user怎么用?Python User.new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.User的用法示例。


在下文中一共展示了User.new_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: new_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
    def new_user(self, email, display_name, password):
        """
        Register new user

        :param str email: User email
        :param str display_name: User name
        :param str password: User password in plain text

        :returns: None

        :raise: UserAlreadyExists
        """
        User.new_user(email, password, display_name)
        return {}
开发者ID:frm-system,项目名称:frm,代码行数:16,代码来源:userapi.py

示例2: process_signup

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def process_signup():
    email, password, name, department = [request.form[attr] for attr in ['email', 'password', 'name', 'department']]
    email = email.lower()
    user = User.new_user(email, password, name, department)
    try:
        user.save()
    except mongoengine.ValidationError as e:
        failed_data = dict(email=email, name=name, department=department)
        return render_template('signup.html', departments=DEPARTMENTS, error=e.message, **failed_data)

    session['logged_in'] = user.email
    return redirect('/')
开发者ID:halflings,项目名称:etic-intervenants,代码行数:14,代码来源:web.py

示例3: process_login

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def process_login():
    email, password = request.form['email'].lower(), request.form['password']
    user = User.objects(email=email).first()
    if user is None or not user.valid_password(password):
        return render_template('login.html', error="Wrong password or username.", email=email)
    else:
        session['logged_in'] = user.email
        inject_user()
        load_user()
        return redirect('/')

@app.route('/api/etude/<etude_id>/notify', methods=['POST'])
def notify_etude(etude_id):
    # TODO : implement sending a mail
    etude = Etude.objects.get(number=etude_id)

    g.user.etudes.append(etude)
    g.user.save()

    app.logger.info('Received notification by user "{}" for etude: \n{}'.format(g.user.name, etude))
    return jsonify(ok=True)


if __name__ == "__main__":
    # Creating dummy user
    User.drop_collection()
    dummy_user = User.new_user(email='[email protected]', password='123456', name='Richard Martin', department='IF')
    dummy_user.save()

    app.run(host='0.0.0.0', debug=True)
开发者ID:halflings,项目名称:etic-intervenants,代码行数:32,代码来源:web.py

示例4: test_new_user

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
    def test_new_user(self):
        User.new_user("[email protected]", "password", "Cool name")

        with self.assertRaises(errors.UserAlreadyExists) as r:
            User.new_user("[email protected]", "password", "Cool name")
开发者ID:frm-system,项目名称:frm,代码行数:7,代码来源:test_user.py


注:本文中的user.User.new_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。