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_password():
"""Reset password of a RAMP user."""
form = EmailForm()
error = ''
if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data).one_or_none()
if user and user.access_level != 'asked':
token = ts.dumps(user.email)
recover_url = url_for(
'auth.reset_with_token', token=token, _external=True
)
subject = "Password reset requested - RAMP website"
body = ('Hi {}, \n\nclick on the link to reset your password:\n'
.format(user.firstname))
body += recover_url
body += '\n\nSee you on the RAMP website!'
send_mail(user.email, subject, body)
logger.info(