-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #525 from NBISweden/fix/only-login-validated-useers
Fix/only login validated users
- Loading branch information
Showing
1 changed file
with
12 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
% ( | ||
|
@@ -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}, | ||
|
@@ -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"]: | ||
|
@@ -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"]) | ||
|