Skip to content

Commit

Permalink
Fixed Adityas request of pw reset error log.
Browse files Browse the repository at this point in the history
  • Loading branch information
DSin52 committed Jan 11, 2016
1 parent bac5158 commit 69225d6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions graphs/static/graphs/js/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $(document).ready(function() {
}, function(data) {

if (data.Error) {
console.log(data);
return alert(data.Error);
} else {
alert("Password Updated!");
Expand Down
7 changes: 4 additions & 3 deletions graphs/util/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ def resetPassword(username, password):
# Hash password
password = bcrypt.hashpw(password, bcrypt.gensalt())
# Update the password for the user (after encryption of course)
user_to_reset_pw_for = db_session.query(models.User).filter(models.User.user_id == username).one()
user_to_reset_pw_for = db_session.query(models.User).filter(models.User.user_id == username).first()
user_to_reset_pw_for.password = password

# Remove user's account from password_reset table
delete_from_password_reset = db_session.query(models.PasswordReset).filter(models.PasswordReset.user_id == username).one()
db_session.delete(delete_from_password_reset)
delete_from_password_reset = db_session.query(models.PasswordReset).filter(models.PasswordReset.user_id == username).all()
for acct in delete_from_password_reset:
db_session.delete(acct)
db_session.commit()
db_session.close()
return "Password updated successfully"
Expand Down
2 changes: 1 addition & 1 deletion graphs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,6 @@ def resetLink(request):
return render(request, 'graphs/error.html', context)

context = {"email": email, "url": URL_PATH}

return render(request, 'graphs/reset.html', context)

def resetPassword(request):
Expand All @@ -899,6 +898,7 @@ def resetPassword(request):
'''
resetInfo = db.resetPassword(request.POST['email'], request.POST['password'])
print resetInfo

if resetInfo == None:
return HttpResponse(json.dumps(db.throwError(500, "Password Update not successful!")), content_type="application/json");
Expand Down

0 comments on commit 69225d6

Please sign in to comment.