Esempio n. 1
0
def set_researcher_password():
    researcher = Researcher.objects.get(
        pk=request.form.get('researcher_id', None))
    new_password = request.form.get('password', '')
    if check_password_requirements(new_password, flash_message=True):
        researcher.set_password(new_password)
    return redirect('/edit_researcher/{:d}'.format(researcher.pk))
Esempio n. 2
0
def reset_admin_password():
    username = session['admin_username']
    current_password = request.values['current_password']
    new_password = request.values['new_password']
    confirm_new_password = request.values['confirm_new_password']
    if not Researcher.check_password(username, current_password):
        flash("The Current Password you have entered is invalid", 'danger')
        return redirect('/manage_credentials')
    if not check_password_requirements(new_password, flash_message=True):
        return redirect("/manage_credentials")
    if new_password != confirm_new_password:
        flash("New Password does not match Confirm New Password", 'danger')
        return redirect('/manage_credentials')
    Researcher.objects.get(username=username).set_password(new_password)
    flash("Your password has been reset!", 'success')
    return redirect('/manage_credentials')