Skip to content

Commit

Permalink
Merge pull request #273 from JumboCode/sfja-272
Browse files Browse the repository at this point in the history
#272 Corrected public auth
  • Loading branch information
Antranduc authored Aug 27, 2020
2 parents 96e9d3a + 9a8ba3f commit 648971f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions api/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
app.config['SENDGRID_DEFAULT_FROM'] = '[email protected]'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

MONGO_URL = os.environ.get('DB_URI')
MONGO_URL = os.environ.get('MONGODB_URI')
app.config["MONGO_URI"] = MONGO_URL
mongo = PyMongo(app)
db = mongo.db
Expand Down Expand Up @@ -181,19 +181,15 @@ def decorated(*args, **kwargs):
def getParentInfo():
curr_link = request.json['curr_link']
try:
parentId = parentsDOM.get(currLink=curr_link)
parent_id = parentsDOM.get(currLink=curr_link)
except AssertionError as e:
raise AuthError({'wrong link': True}, 401)

if parentsDOM.isExpired(parent_id):
emailParent(parent_id,'', 'Your updated link is below:')
raise AuthError({'expired': True}, 426)

parentInfo = parentsDOM.getParentProfile(parentId)

if parentsDOM.isExpired(parentId):
emailParent(parentId,'', 'Your updated link is below:')
raise AuthError({'expired': True}, 426)
parentInfo = parentsDOM.getParentProfile(parent_id)

return {
'first_name': parentInfo['first_name'],
Expand All @@ -205,7 +201,7 @@ def getParentInfo():
def getStudentsOfParent():
curr_link = request.json['curr_link']
try:
parentId = parentsDOM.get(currLink=curr_link)
parent_id = parentsDOM.get(currLink=curr_link)
except AssertionError as e:
raise AuthError({'wrong link': True}, 401)

Expand All @@ -214,7 +210,7 @@ def getStudentsOfParent():
raise AuthError({'expired': True}, 426)


all_student_ids = parentsDOM.getStudentIds(parentId)
all_student_ids = parentsDOM.getStudentIds(parent_id)
unarchived_student_ids = []
for id in all_student_ids:
if not studentsDOM.isArchived(id):
Expand All @@ -233,7 +229,7 @@ def getStudentForms():
student_id = ObjectId(request.json['student_id'])
curr_link = request.json['parent_key']
try:
parentId = parentsDOM.get(currLink=curr_link)
parent_id = parentsDOM.get(currLink=curr_link)
except AssertionError as e:
raise AuthError({'wrong link': True}, 401)

Expand Down Expand Up @@ -265,7 +261,7 @@ def getStudentForms():
def getForm():
curr_link = request.json['curr_link']
try:
parentId = parentsDOM.get(currLink=curr_link)
parent_id = parentsDOM.get(currLink=curr_link)
except AssertionError as e:
raise AuthError({'wrong link': True}, 401)

Expand All @@ -288,10 +284,14 @@ def getForm():
def submitForm():
curr_link = request.json['curr_link']
try:
parentId = parentsDOM.get(currLink=curr_link)
parent_id = parentsDOM.get(currLink=curr_link)
except AssertionError as e:
raise AuthError({'wrong link': True}, 401)

if parentsDOM.isExpired(parent_id):
emailParent(parent_id,'', 'Your updated link is below:')
raise AuthError({'expired': True}, 426)

form_id = request.json['form_id']
answer_data = request.json['answer_data']
FormsDOM.updateFormData(form_id, answer_data)
Expand Down

0 comments on commit 648971f

Please sign in to comment.