-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,246 additions
and
105 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
ignore= W293 | ||
ignore= W293,W503 |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"MD024": { | ||
"siblings_only": true | ||
}, | ||
"MD033": false, | ||
"MD036": false, | ||
"MD046": false | ||
} |
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
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
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
"""This module is used to authenticate users to the system and | ||
handle few authentication errors. Also, it sets token for logged user | ||
along with expiration date""" | ||
import datetime | ||
import importlib | ||
import os | ||
import re | ||
|
||
# import config | ||
import uuid | ||
from datetime import timezone | ||
from typing import Any, Union | ||
|
@@ -37,11 +38,16 @@ | |
|
||
|
||
class UnauthenticatedException(Exception): | ||
"""Exception raised when a user is not authenticated.""" | ||
|
||
# TODO: Implement this exception | ||
pass | ||
|
||
|
||
@api.route("/auth/signup") | ||
class SignUpUser(Resource): | ||
"""SignUpUser class is used to sign up new users to the system""" | ||
|
||
@api.response(200, "Success") | ||
@api.response(400, "Validation Error") | ||
# @api.marshal_with(signup_model) | ||
|
@@ -50,7 +56,14 @@ def post(self): | |
"""signs up the new users and saves data in DB""" | ||
data: Union[Any, dict] = request.json | ||
if os.environ.get("FLASK_ENV") != "testing": | ||
if data["email_address"] not in ["[email protected]"]: | ||
bypassed_emails = [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
|
||
if data["email_address"] not in bypassed_emails: | ||
invite = model.StudyInvitedContributor.query.filter_by( | ||
email_address=data["email_address"] | ||
).one_or_none() | ||
|
@@ -144,6 +157,8 @@ def validate_password(instance): | |
|
||
@api.route("/auth/login") | ||
class Login(Resource): | ||
"""Login class is used to login users to the system""" | ||
|
||
@api.response(200, "Success") | ||
@api.response(400, "Validation Error") | ||
# @api.marshal_with(login_model) | ||
|
@@ -156,9 +171,8 @@ def post(self): | |
email_address = data["email_address"] | ||
|
||
def validate_is_valid_email(instance): | ||
print("within is_valid_email") | ||
email_address = instance | ||
print(email_address) | ||
|
||
try: | ||
validate_email(email_address) | ||
return True | ||
|
@@ -352,16 +366,10 @@ def is_granted(permission: str, study=None): | |
return permission in role[contributor.permission] | ||
|
||
|
||
# | ||
# def is_study_metadata(study_id: int): | ||
# study_obj = model.Study.query.get(study_id) | ||
# if not is_granted("study_metadata", study_obj): | ||
# return "Access denied, you can not delete study", 403 | ||
# | ||
|
||
|
||
@api.route("/auth/logout") | ||
class Logout(Resource): | ||
"""Logout class is used to log out users from the system""" | ||
|
||
@api.response(200, "Success") | ||
@api.response(400, "Validation Error") | ||
def post(self): | ||
|
@@ -379,14 +387,15 @@ def post(self): | |
return resp | ||
|
||
|
||
@api.route("/auth/current-users") | ||
class CurrentUsers(Resource): | ||
"""function is used to see all logged users in | ||
the system. For now, it is used for testing purposes""" | ||
# @api.route("/auth/current-users") | ||
# class CurrentUsers(Resource): | ||
# """function is used to see all logged users in | ||
# the system. For now, it is used for testing purposes""" | ||
|
||
@api.response(200, "Success") | ||
@api.response(400, "Validation Error") | ||
def get(self): | ||
if not g.user: | ||
return None | ||
return g.user.to_dict() | ||
# @api.response(200, "Success") | ||
# @api.response(400, "Validation Error") | ||
# def get(self): | ||
# """returns all logged users in the system""" | ||
# if not g.user: | ||
# return None | ||
# return g.user.to_dict() |
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
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
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
Oops, something went wrong.