MCPcopy Create free account
hub / github.com/codemistic/Web-Development / ForgetPassword

Function ForgetPassword

email verification/src/accounts/views.py:120–142  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

118
119import uuid
120def ForgetPassword(request):
121 try:
122 if request.method =="POST":
123 username = request.POST.get('username')
124 print("success")
125
126 if not User.objects.filter(username=username).first():
127 print("user not found")
128 messages.success(request,"No user found.")
129 return redirect("/forget-password/")
130
131 user_obj=User.objects.get(username=username)
132 token=str(uuid.uuid4())
133 profile_obj1=Prof2.objects.get(user=user_obj)
134 profile_obj1.forget_password_token=token
135 profile_obj1.save()
136 send_forget_password_mail(user_obj.email,token)
137 messages.success(request,"An email is sent")
138 return redirect("/forget-password/")
139 except Exception as e:
140 print(e)
141
142 return render(request,'forget-password.html')
143
144
145def ChangePassword(request,token):

Callers

nothing calls this directly

Calls 3

renderFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected