Browse Source

Merge branch 'master' of git.craftbroec.nl:da/website

Joost Sijm 2 năm trước cách đây
mục cha
commit
8351731635

+ 15 - 15
app/modules/auth/app.py

@@ -26,18 +26,21 @@ def login():
         email = request.form['email']
         password = request.form['password']
         user = User.query.filter(User.email == email).first()
-        if user:
-            if not user.approved:
-                flash('Account not approved yet.', 'warning')
-            if user.check_password(password):
-                login_user(user, remember=True)
-                flash('Successfully loggend in.', 'success')
-                if request.args.get("next"):
-                    return redirect(request.args.get('next'))
-                return redirect(url_for('backend.index'))
+        if not user:
+            flash('Email not found.', 'warning')
+            return render_template('login.j2')
+        if not user.approved:
+            flash('Account not approved yet.', 'warning')
+            return render_template('login.j2', login_email=email)
+        if not user.check_password(password):
             flash('Password Incorrect.', 'warning')
             return render_template('login.j2', login_email=email)
-        flash('Email not found.', 'warning')
+        login_user(user, remember=True)
+        flash('Successfully loggend in.', 'success')
+        if request.args.get("next") and request.args.get("next") != "/logout":
+            print(request.args.get("next"))
+            return redirect(request.args.get('next'))
+        return redirect(url_for('backend.index'))
     return render_template('login.j2')
 
 
@@ -70,10 +73,7 @@ def register():
     user = User.query.filter(User.email == email).first()
     if user is not None:
         flash('Email already taken.', 'warning')
-        return render_template(
-            'login.j2',
-            name=name,
-        )
+        return redirect(url_for('auth.login'))
 
     user = User()
     user.name = name
@@ -84,7 +84,7 @@ def register():
     db.session.commit()
 
     flash('Successfully registered account "%s". Wait for verfication.' % (user.name), 'success')
-    return render_template('login.j2')
+    return redirect(url_for('auth.login'))
 
 
 @BLUEPRINT.route("/logout")

+ 1 - 1
app/modules/auth/templates/login.j2

@@ -19,7 +19,7 @@
                 {% if messages %}
                 {% for category, message in messages %}
                 <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
-                    {{ message }}
+                    <span>{{ message }}</span>
                     <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                         <span aria-hidden="true">&times;</span>
                     </button>

+ 1 - 1
app/templates/layout/backend.j2

@@ -37,7 +37,7 @@
         {% if messages %}
         {% for category, message in messages %}
         <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
-            {{ message }}
+            <span>{{ message }}</span>
             <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                 <span aria-hidden="true">&times;</span>
             </button>

+ 0 - 3
migrations/versions/c98e920c06ae_add_ballots_remove_page_file_relation.py

@@ -68,10 +68,7 @@ def upgrade():
     op.add_column('user', sa.Column('party_member', sa.Boolean(), server_default='f', nullable=True))
     op.add_column('user', sa.Column('question_id', sa.Integer(), nullable=True))
     op.create_unique_constraint(op.f('uq_user_discord'), 'user', ['discord'])
-    op.create_unique_constraint(op.f('uq_user_email'), 'user', ['email'])
     op.create_unique_constraint(op.f('uq_user_game_id'), 'user', ['game_id'])
-    op.create_unique_constraint(op.f('uq_user_name'), 'user', ['name'])
-    op.drop_constraint('user_name_key', 'user', type_='unique')
     op.create_foreign_key(op.f('fk_user_question_id_question'), 'user', 'question', ['question_id'], ['id'])