Пример #1
0
def login():
    if authentication.is_authenticated(flask.session):
        return flask.redirect(open_id.get_next_url())

    root = authentication.request_macaroon()
    openid_macaroon = MacaroonRequest(
        caveat_id=authentication.get_caveat_id(root))
    flask.session['macaroon_root'] = root

    return open_id.try_login(LOGIN_URL,
                             ask_for=['email', 'nickname', 'image'],
                             ask_for_optional=['fullname'],
                             extensions=[openid_macaroon])
Пример #2
0
    def is_user_logged_in(*args, **kwargs):
        if not authentication.is_authenticated(flask.session):
            return redirect_to_login()

        return func(*args, **kwargs)
Пример #3
0
def logout():
    if authentication.is_authenticated(flask.session):
        authentication.empty_session(flask.session)
    return flask.redirect('/')
Пример #4
0
    def is_user_logged_in(*args, **kwargs):
        if not authentication.is_authenticated(flask.session):
            return flask.redirect('login?next=' + flask.request.path)

        return func(*args, **kwargs)