initial functionality and styling pass
This commit is contained in:
+18
-2
@@ -15,11 +15,27 @@ def register():
|
||||
form = RegistrationForm()
|
||||
if form.validate_on_submit():
|
||||
hashed_password = generate_password_hash(form.password.data)
|
||||
user = User(username=form.username.data, email=form.email.data, password_hash=hashed_password)
|
||||
|
||||
# Check if any users exist
|
||||
is_first_user = User.query.count() == 0
|
||||
|
||||
user = User(
|
||||
username=form.username.data,
|
||||
email=form.email.data,
|
||||
password_hash=hashed_password,
|
||||
is_admin=is_first_user # Make first user an admin
|
||||
)
|
||||
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
flash('Account created! Please log in.', 'success')
|
||||
|
||||
if is_first_user:
|
||||
flash('Account created as administrator.', 'success')
|
||||
else:
|
||||
flash('Account created! Please log in.', 'success')
|
||||
|
||||
return redirect(url_for('auth.login'))
|
||||
|
||||
return render_template('register.html', form=form)
|
||||
|
||||
@auth.route('/login', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user