def create_or_login(resp) -> Response: 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())
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())
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 = munch.Munch({ "username": "******", "email": "admin@localhost", "admin": True })
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 = munch.Munch({ "username": "******", "email": "admin@localhost", "admin": True })