Fix new user creation
This commit is contained in:
Binary file not shown.
@@ -114,10 +114,14 @@ def new_contact():
|
||||
is_admin=form.is_admin.data,
|
||||
profile_picture=profile_picture
|
||||
)
|
||||
user.set_password('changeme') # Set a default password that must be changed
|
||||
if form.new_password.data:
|
||||
user.set_password(form.new_password.data)
|
||||
else:
|
||||
flash('Password is required when creating a new user.', 'error')
|
||||
return render_template('contacts/form.html', form=form, title='New User', total_admins=total_admins)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
flash('User created successfully! They will need to set their password on first login.', 'success')
|
||||
flash('User created successfully!', 'success')
|
||||
return redirect(url_for('contacts.contacts_list'))
|
||||
return render_template('contacts/form.html', form=form, title='New User', total_admins=total_admins)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user