Exemple #1
0
def create_or_login(resp):
    flask.session["openid"] = resp.identity_url
    username = fed_raw_name(resp.identity_url)

    privileged = False
    # "lp" is the namespace for openid-teams
    if "lp" in resp.extensions and any(group in app.config["OPENID_PRIVILEGED_TEAMS"]
                                       for group in resp.extensions["lp"].teams):
        privileged = True

    user = db.session.query(User).filter(User.username == username).first()
    if not user:  # create
        user = User(username=username, mail=resp.email, privileged=privileged)
    else:
        user.mail = resp.email
        user.privileged = privileged

    db.session.add(user)
    db.session.commit()
    flask.flash(u"Welcome, {0}".format(user.username))
    flask.g.user = user

    if flask.request.url_root == oid.get_next_url():
        return flask.redirect(flask.url_for("summary.index"))

    return flask.redirect(oid.get_next_url())
Exemple #2
0
def before_request():
    flask.g.user = None
    if "openid" in flask.session:
        username = fed_raw_name(flask.session["openid"])
        flask.g.user = (db.session.query(User)
                        .filter(User.username == username)
                        .first())
Exemple #3
0
def create_or_login(resp):
    flask.session["openid"] = resp.identity_url
    username = fed_raw_name(resp.identity_url)

    privileged = False
    # "lp" is the namespace for openid-teams
    if "lp" in resp.extensions and any(
            group in app.config["OPENID_PRIVILEGED_TEAMS"]
            for group in resp.extensions["lp"].teams):
        privileged = True

    user = db.session.query(User).filter(User.username == username).first()
    if not user:  # create
        user = User(username=username, mail=resp.email, privileged=privileged)
    else:
        user.mail = resp.email
        user.privileged = privileged

    db.session.add(user)
    db.session.commit()
    flask.flash(u"Welcome, {0}".format(user.username))
    flask.g.user = user

    if flask.request.url_root == oid.get_next_url():
        return flask.redirect(flask.url_for("summary.index"))

    return flask.redirect(oid.get_next_url())
Exemple #4
0
def before_request():
    flask.g.user = None
    if "openid" in flask.session:
        username = fed_raw_name(flask.session["openid"])
        flask.g.user = (db.session.query(User).filter(
            User.username == username).first())

    elif app.config["EVERYONE_IS_ADMIN"]:
        flask.g.user = bunch.Bunch({
            "username": "******",
            "email": "admin@localhost",
            "admin": True
        })
Exemple #5
0
def before_request():
    flask.g.user = None
    if "openid" in flask.session:
        username = fed_raw_name(flask.session["openid"])
        flask.g.user = (db.session.query(User)
                        .filter(User.username == username)
                        .first())

    elif app.config["EVERYONE_IS_ADMIN"]:
        flask.g.user = bunch.Bunch({
            "username": "******",
            "email": "admin@localhost",
            "admin": True
        })
Exemple #6
0
def create_or_login(resp):
    flask.session["openid"] = resp.identity_url
    username = fed_raw_name(resp.identity_url)

    user = db.session.query(User).filter(User.username == username).first()
    if not user:  # create
        user = User(username=username, mail=resp.email)
    else:
        user.mail = resp.email

    db.session.add(user)
    db.session.commit()
    flask.flash(u"Welcome, {0}".format(user.username))
    flask.g.user = user

    if flask.request.url_root == oid.get_next_url():
        return flask.redirect(flask.url_for("summary.index"))

    return flask.redirect(oid.get_next_url())
Exemple #7
0
def before_request():
    flask.g.user = None
    if "openid" in flask.session:
        username = fed_raw_name(flask.session["openid"])
        flask.g.user = (db.session.query(User).filter(
            User.username == username).first())