Skip to content

Commit

Permalink
Merge pull request #525 from NBISweden/fix/only-login-validated-useers
Browse files Browse the repository at this point in the history
Fix/only login validated users
  • Loading branch information
jhagberg authored Sep 16, 2022
2 parents a927561 + db77eef commit 9187866
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/herdbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ def external_login_handler(service):

user = da.authenticate_with_credentials(service, persistent_id)

if user:
if user and not user.validated:
return "Du behöver gå en kurs och bli validerad först kontakta [email protected]"

if user and user.validated:
APP.logger.info(
"Logging in user %s (%s - #%d) by persistent id %s for service %s, refferrer is %s"
% (
Expand Down Expand Up @@ -504,7 +507,7 @@ def external_login_handler(service):
accountdetails["email"],
None,
username=accountdetails["username"],
validated=True,
validated=False,
fullname=accountdetails["fullname"] if "fullname" in accountdetails else None,
privileges=[
{"level": "viewer", "genebank": 1},
Expand Down Expand Up @@ -533,9 +536,6 @@ def external_login_handler(service):
% (persistent_id, accountdetails["email"], service)
)

# FIXME: this is how we "really" log in the user
session["user_id"] = user.uuid

# If we got a herd from external, setup ownership
if "herd" in accountdetails:
for h in ["G", "M"]:
Expand All @@ -552,9 +552,13 @@ def external_login_handler(service):
else:
APP.logger.warning("Could not find herd id for herd %s" % h.strip())

login_user(user)

return redirect("/start")
# FIXME: this is how we "really" log in the user
if user.validated:
session["user_id"] = user.uuid
login_user(user)
return redirect("/start")
else:
return "Du behöver gå en kurs och bli validerad först kontakta [email protected]"


@APP.route("/api/link/<string:service>", methods=["GET", "POST"])
Expand Down

0 comments on commit 9187866

Please sign in to comment.