def confirm(req, token): try: email = simple_encrypt.decrypt(token) account = Account.objects.get(email=email) account.is_active = True account.save() messages.add_message(req, messages.SUCCESS, "Your email has been confirmed. You can login now.") except: messages.add_message(req, messages.ERROR, "Invalid confirmation token.") return redirect(index)
def validate_token(req, token): try: data = simple_encrypt.decrypt(token) except: messages.add_message(req, messages.ERROR, "Invalid link") return redirect(INDEX_PAGE), False data = data.split(",,,") if len(data) != 2: messages.add_message(req, messages.ERROR, "Invalid link") return redirect(INDEX_PAGE), False return data, True
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: messages.add_message(req, messages.ERROR, "Invalid link") return redirect(INDEX_PAGE), False data = data.split(",,,") if len(data) != 2: messages.add_message(req, messages.ERROR, "Invalid link") return redirect(INDEX_PAGE), False return data, True
def confirm(req, token): """ Confirms a user's email-id. Generate user alerts if: User enters invalid confirmation token. User's email-id gets confirmed. Input: s:request object. Output: HttpResponseRedirect object returned by redirect() function. """ try: email = simple_encrypt.decrypt(token) account = Account.objects.get(email=email) account.is_active = True account.save() messages.add_message( req, messages.SUCCESS, "Your email has been confirmed. You can login now.") except: messages.add_message(req, messages.ERROR, "Invalid confirmation token.") return redirect(index)