summaryrefslogtreecommitdiff
path: root/password
diff options
context:
space:
mode:
authorvikas1792017-06-23 10:45:58 +0530
committervikas1792017-06-23 10:48:02 +0530
commit294d54dac2b8715891ac32d9b93b3bfd885827f6 (patch)
tree5f174a6b40f3abb6db877162c77ad311e89dfc8f /password
parent470fc4aa20fc68fd0d3ef5c94768a39f3623765c (diff)
downloadSBHS-2018-Rpi-294d54dac2b8715891ac32d9b93b3bfd885827f6.tar.gz
SBHS-2018-Rpi-294d54dac2b8715891ac32d9b93b3bfd885827f6.tar.bz2
SBHS-2018-Rpi-294d54dac2b8715891ac32d9b93b3bfd885827f6.zip
add further docstrings
Diffstat (limited to 'password')
-rw-r--r--password/views.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/password/views.py b/password/views.py
index c0323a3..67406ed 100644
--- a/password/views.py
+++ b/password/views.py
@@ -8,12 +8,25 @@ import datetime
# Create your views here.
def new(req):
+ """ Returns html page to set new password
+ Input: request object
+ Output: renders new.html page through render function.
+ """
return render(req, 'password/new.html')
def password_token(username):
+ """ Returns encrypted token
+ Input: username
+ Output: encrypted token returned by encrypt() function.
+ """
return simple_encrypt.encrypt(username + ",,," + str(datetime.datetime.now()))
def email(req):
+ """ Sends the reset password link to the email
+ Checks if the user has an account
+ Input: request object
+ Output: INDEX_PAGE returned by redirect() function.
+ """
email = req.POST.get("email")
account = Account.objects.filter(email=email)
@@ -24,6 +37,12 @@ def email(req):
return redirect(INDEX_PAGE)
def validate_token(req, token):
+ """ Checks if the token is valid
+ Decrypts token and checks for validity
+ Input: request object, token.
+ Output: INDEX_PAGE returned by redirect() function if Invalid link
+ data if Valid link.
+ """
try:
data = simple_encrypt.decrypt(token)
except:
@@ -38,6 +57,13 @@ def validate_token(req, token):
return data, True
def edit(req, token):
+ """ Makes user able to edit the password
+ calculates the time and checks if reset link is expired
+ Input: request object, token
+ Output: renders edit.html page if link is not expired
+ shows error message if link is expired and returns the Index_page through redirect()
+ function.
+ """
data, flag = validate_token(req, token)
if not flag:
return data
@@ -51,6 +77,15 @@ def edit(req, token):
return redirect(INDEX_PAGE)
def update(req, token):
+ """ Makes user able to update the password
+ -Checks if token is valid
+ -Checks if the link is expired
+ -Checks if email entered by user is valid
+ -Checks if passwords of password and confirm field matches
+ Input: request object , token.
+ Output: Message "Password changed successfully" if success
+ Message "Invalid link" or "Reset link is expired" if respective validations fails.
+ """
data, flag = validate_token(req, token)
if not flag:
return data