Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def reset_with_token(token):
"""Reset password by passing a token (email).
Parameters
----------
token : str
The token associated with an email address.
"""
try:
email = ts.loads(token, max_age=86400)
except Exception as e:
logger.error(str(e))
abort(404)
form = PasswordForm()
if form.validate_on_submit():
user = User.query.filter_by(email=email).one_or_none()
if user is None:
logger.error('The error was deleted before resetting his/her '
'password')
abort(404)
(User.query.filter_by(email=email)
.update({
"hashed_password":
hash_password(form.password.data).decode()}))
db.session.commit()
return redirect(url_for('auth.login'))
return render_template('reset_with_token.html', form=form, token=token)