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


Python User.authenticate方法代码示例

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


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

示例1: create_internal

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
	def create_internal(self, user, password):
		user_id = User.create(user, password)

		assert User.authenticate(user_id, password)
		assert not User.authenticate(user_id, "otherpassword")
		assert not User.authenticate(user_id, user)

		recreated_user = User(user_id)
		assert_equals(user_id, recreated_user.user_id)
		assert_equals(user, recreated_user.name)
开发者ID:jwmcglynn,项目名称:videosync,代码行数:12,代码来源:test_user.py

示例2: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
 def post(self, *args, **kwargs):
     name = self.get_argument("name", None)
     pwd = self.get_argument("pwd", None)
     user_doc = User.authenticate(name, pwd)
     if user_doc:
         self.write(self.make_result(1, "login OK", user_doc))
     else:
         self.write(self.make_result(0, "user not found or wrong password", None))
开发者ID:jungor,项目名称:android_final_project,代码行数:10,代码来源:server.py

示例3: login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
def login(email, password):
    user = User.authenticate(email, password)
    if user:
        session['user_id'] = str(user.id)
        return { 'is_accepted': True,
                'message':'User accepted'}
    else:
        return {'is_accepted':False,
                'message': 'Wrong email and password'}
开发者ID:Rmanolis,项目名称:rpg-demo,代码行数:11,代码来源:authentication.py

示例4: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
 def post(self):
     email = self.get_argument('email', '')
     password = self.get_argument('password', '')
     user = User.authenticate(email=email, password=password)
     if user is not None:
         self.set_current_user(user)
         self.redirect(self.reverse_url(name='index'))
     else:
         error_message = 'ユーザ名かパスワードが間違っています。'
         self.render('auth/login.html', error_message=error_message)
开发者ID:ko-he-,项目名称:Brain_Hacker,代码行数:12,代码来源:auth_handler.py

示例5: login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
def login():
    form = LoginForm()
    if request.method == 'POST':
        if form.validate_on_submit():

            user, authenticated = User.authenticate(form.username.data,
                                                form.password.data)

            if user and authenticated:
                login_user(user, remember=form.remember_me.data)
                return url_for('map.devices_on_map')
            else:
                return make_response(422, message='Incorrect username or password.')

    return render_template('login.html', title='Sign In', form=form)
开发者ID:qitianchan,项目名称:new-busad,代码行数:17,代码来源:auth.py

示例6: login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
def login():
    if request.method == 'GET':
        return render_template('base_index.html')

    if request.method == 'POST':
        form = LoginForm(request.form)
        if form.validate():
            username = form.data.get('username', '')
            password = form.data.get('password', '')

            admin_user = User.authenticate(username, password)
            if admin_user:
                return_status(200)
            else:
                return_status(400)
        else:
            return_status(401)
开发者ID:annieqin,项目名称:PersonalWebsite,代码行数:19,代码来源:admin.py

示例7: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
    def post(self):
        form = LoginForm(self.request.arguments)

        if form.validate():
            username = form.data.get('username', '')
            password = form.data.get('password', '')

            user = User.authenticate(username, password)
            if user:
                user.last_login_at = datetime.datetime.now()
                user.last_login_ip = self.request.remote_ip
                user.save()

                self.set_secure_cookie('user_id', str(user.id))
                self.redirect(self.reverse_url('admin'))
            else:
                return self.return_status(400, '用户名或密码错误')
        else:
            return self.return_status(400, form.errors)
开发者ID:hooops,项目名称:PersonalWebsite,代码行数:21,代码来源:user.py

示例8: validate

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import authenticate [as 别名]
 def validate(self):
     if not Form.validate(self):
         return False
     return User.authenticate(email=self.data['email'], password=self.data['password'])
开发者ID:Hironsan,项目名称:tornado_auth,代码行数:6,代码来源:forms.py


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