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


Python User.authenticate方法代码示例

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


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

示例1: Authentication

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
class Authentication(object):

    def __init__(self):
        self.__view = View()
        self.__user = User(
            b'$2b$10$j/sucIARrrAq88IlBrXede7C5IVQ4rAZ7QHfCHQvZhJnQxd3CCelm')

    def run(self):
        password = self.__view.do_login()
        self.__user.authenticate(password)
        if self.__user.is_authenticated:
            self.__view.login_successful()
        else:
            self.__view.login_failed()
        return self.__user.is_authenticated
开发者ID:rk222ev,项目名称:1dv607_Member_registry,代码行数:17,代码来源:authentication.py

示例2: decorated_function

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
    def decorated_function(*args, **kwargs):
        authenticated = False

        if g.user.id is not None:
            authenticated = True

        elif request.authorization is not None:
            user = User.authenticate(request.authorization['username'],
                                     request.authorization['password'])
            if user is not None:
                g.user = user
                authenticated=True

        elif 'authorization' in request.headers:
            match = api_key_re.match(request.headers['authorization'])
            if match:
                user, device = Device.authenticate(match.group(1))
                if user is not None:
                    g.user = user
                    g.device = device
                    authenticated = True

        if authenticated:
            return f(*args, **kwargs)
        abort(403)
开发者ID:noswap,项目名称:keyring,代码行数:27,代码来源:auth.py

示例3: get

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def get(self, user_id, category_id):
     auth_key = request.args.get('key')
     user = User.authenticate(user_id, auth_key)
     if user:
         if category_id:
             return json.jsonify(user.categories.filter_by(category_id=category_id).first_or_404().as_dict())
         return json.jsonify({'categories': [category.as_dict() for category in user.categories]})
     return json.jsonify({})
开发者ID:felipemfp,项目名称:minhaeiroAPI,代码行数:10,代码来源:apis.py

示例4: delete

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def delete(self, user_id):
     auth_key = request.args.get('key')
     user = User.authenticate(user_id, auth_key)
     if user:
         db.session.delete(user)
         db.session.commit()
         return json.jsonify({'success': '{} was deleted'.format(user)})
     return json.jsonify({})
开发者ID:felipemfp,项目名称:minhaeiroAPI,代码行数:10,代码来源:apis.py

示例5: user

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
def user():
    app.logger.info('formdata {}'.format(request.form))
    email = request.form.get('email')
    password = request.form.get('password')
    # todo validation
    user = User.authenticate(email, password)
    # todo return proper token
    return user.key.urlsafe()
开发者ID:Tjorriemorrie,项目名称:twurl,代码行数:10,代码来源:views.py

示例6: validate

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def validate(self):
     if not super(LoginForm, self).validate():
         return False
         
     self.user = User.authenticate(self.email.data, self.password.data)
     if not self.user:
         self.email.errors.append("Invalid email or password.")
         return False
     return True
开发者ID:octt,项目名称:flask,代码行数:11,代码来源:forms.py

示例7: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
    def post(self):
        args = self.parser.parse_args()

        user, authenticated = User.authenticate(args.username, args.password)
        if authenticated:
            login_user(user, remember=args.remember_me)
            return { 'username': user.name, 'authenticated': True }
        else:
            return { 'authenticated': False }, 401 
开发者ID:omwah,项目名称:expo_track,代码行数:11,代码来源:api.py

示例8: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
def login():
    email = request.form['email']
    password = request.form['password']
    user = User.authenticate(email, password)
    if user:
        session['user_id'] = user.id
        return redirect("/class-list")
    else:
        flash("Incorrect email or password", "alert-danger")
        return redirect("/")
开发者ID:asgordon96,项目名称:bush-schedule,代码行数:12,代码来源:app.py

示例9: put

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def put(self, user_id, person_id):
     auth_key = request.args.get('key')
     user = User.authenticate(user_id, auth_key)
     if user:
         new_person = request.get_json(force=True)
         person = user.people.filter_by(person_id=person_id).first_or_404()
         person.name = new_person['name']
         db.session.commit()
         return json.jsonify(person.as_dict())
     return json.jsonify({})
开发者ID:felipemfp,项目名称:minhaeiroAPI,代码行数:12,代码来源:apis.py

示例10: mypost

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def mypost(self):
     self.err[None] = User.authenticate(
         self,
         self.request.get('email'),
         self.request.get('pwd')
     )
     if self.err[None] is None:
         # The time.sleep is necessary because otherwise the database
         # hasn't updated so there is no-one to log in as
         time.sleep(0.1)
         self.redirect(LIST_COURSES_URL)
开发者ID:matts1,项目名称:MajorWork-appengine,代码行数:13,代码来源:login.py

示例11: verify_password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
def verify_password(username_or_token, password):
    # first try to authenticate by token
    user = User.verify_auth_token(username_or_token)
    if not user:
        # try to authenticate with username/password
        db_session = DBSession()
        user = db_session.query(User).filter_by(username=username_or_token).first()
        if not user or not User.authenticate(db_session.query, username_or_token, password):
            return False
    g.user = user
    current_user = g.user
    return True
开发者ID:kstaniek,项目名称:csm,代码行数:14,代码来源:api.py

示例12: post

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def post(self, user_id):
     auth_key = request.args.get('key')
     user = User.authenticate(user_id, auth_key)
     if user:
         supposed_person = request.get_json(force=True)
         person = Person()
         person.user_id = user_id
         person.name = supposed_person['name']
         db.session.add(person)
         db.session.commit()
         if person.person_id:
             return json.jsonify(person.as_dict())
     return json.jsonify({})
开发者ID:felipemfp,项目名称:minhaeiroAPI,代码行数:15,代码来源:apis.py

示例13: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
def login():
    if g.user is not None and g.user.is_authenticated():
        return redirect(url_for('index'))

    form = LoginForm()
    if form.validate_on_submit():
        u = User.authenticate(form.email.data, form.pwd.data)
        if u is not None:
            flash("Login Succeed!")
            login_user(u, remember=form.remember_me.data)
            return redirect(url_for('index'))
        flash(gettext("Error in login..."))
    return render_template('login.html', title='Sign In', form=form)
开发者ID:archieyang,项目名称:microblog,代码行数:15,代码来源:views.py

示例14: GET

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
 def GET(self):
     user_data = web.input()
     form = forms.login_form()
     if not form.validates():
         return render.login(forms.registration_form(), form)
     user = User.authenticate(user_data.email, user_data.password)
     if user is not None:
         session = Session(user.id)
         session.save()
         web.seeother("/account")
     else:
         form.note = "There is no such email and password in our database"
         return render.login(forms.registration_form(), form)
开发者ID:lobodin,项目名称:some-kinda-store,代码行数:15,代码来源:controllers.py

示例15: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import authenticate [as 别名]
def login():
    form = LoginForm(request.form)
    error = None
    if request.method == 'POST' and form.validate():
        uname = form.username.data
        pw = form.password.data
        user, authenticated = User.authenticate(mongo.db, uname, pw)
        if authenticated:
            login_user(user)
            return redirect(url_for('admin'))
        else:
            error = 'Incorrect username or password.'
    return render_template('login.html', form=form, error=error)
开发者ID:NSkelsey,项目名称:muckhacker,代码行数:15,代码来源:app.py


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