diff --git a/app/auth/forms.py b/app/auth/forms.py index 2f03f1b1..b366c05e 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -6,7 +6,7 @@ from wtforms.validators import DataRequired, Email, EqualTo, Length, Regexp class LoginForm(FlaskForm): - login = StringField('Login', validators=[DataRequired(), Length(1, 64)]) + user = StringField('Email address or username', validators=[DataRequired(), Length(1, 64)]) password = PasswordField('Password', validators=[DataRequired()]) remember_me = BooleanField('Keep me logged in') submit = SubmitField('Log In') diff --git a/app/auth/views.py b/app/auth/views.py index 22a11954..37f054e7 100644 --- a/app/auth/views.py +++ b/app/auth/views.py @@ -3,32 +3,13 @@ from app.email import send_email from app.models import User from flask import (current_app, flash, redirect, render_template, request, url_for) -from flask_login import current_user, login_required, login_user, logout_user +from flask_login import current_user, login_required, logout_user from . import auth -from .forms import (LoginForm, PasswordResetForm, PasswordResetRequestForm, +from .forms import (PasswordResetForm, PasswordResetRequestForm, RegistrationForm) import os -@auth.route('/login', methods=['GET', 'POST']) -def login(): - if current_user.is_authenticated: - return redirect(url_for('main.index')) - form = LoginForm() - if form.validate_on_submit(): - user = User.query.filter_by(email=form.login.data).first() - if user is None: - user = User.query.filter_by(username=form.login.data).first() - if user is not None and user.verify_password(form.password.data): - login_user(user, form.remember_me.data) - next = request.args.get('next') - if next is None or not next.startswith('/'): - next = url_for('main.dashboard') - return redirect(next) - flash('Invalid username or password.') - return render_template('auth/login.html.j2', form=form, title='Log in') - - @auth.route('/logout') @login_required def logout(): diff --git a/app/main/views.py b/app/main/views.py index 62c89b41..c64d1b01 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -1,11 +1,26 @@ -from flask import render_template -from flask_login import login_required +from app.auth.forms import LoginForm +from app.models import User +from flask import flash, redirect, render_template, request, url_for +from flask_login import login_required, login_user from . import main -@main.route('/') +@main.route('/', methods=['GET', 'POST']) def index(): - return render_template('main/index.html.j2', title='nopaque') + login_form = LoginForm(prefix='login-form') + if login_form.validate_on_submit(): + user = User.query.filter_by(email=login_form.user.data).first() + if user is None: + user = User.query.filter_by(username=login_form.user.data).first() + if user is not None and user.verify_password(login_form.password.data): + login_user(user, login_form.remember_me.data) + next = request.args.get('next') + if next is None or not next.startswith('/'): + next = url_for('main.dashboard') + return redirect(next) + flash('Invalid username or password.') + return render_template('main/index.html.j2', login_form=login_form, + title='nopaque') @main.route('/dashboard') diff --git a/app/templates/jobs/job.html.j2 b/app/templates/jobs/job.html.j2 index 77ea9a5d..b0e10fe1 100644 --- a/app/templates/jobs/job.html.j2 +++ b/app/templates/jobs/job.html.j2 @@ -251,7 +251,7 @@ var informationUpdater = new InformationUpdater({{ job.id }}, false); {% else %} var informationUpdater = new InformationUpdater({{ job.id }}, true); - nopaque.socket.emit('subscribe_foreign_user_ressources', {{ job.user_id }}); + nopaque.socket.emit('foreign_user_ressources_init', {{ job.user_id }}); {% endif %} {% endblock %} diff --git a/app/templates/main/index.html.j2 b/app/templates/main/index.html.j2 index e9d4338d..672794a2 100644 --- a/app/templates/main/index.html.j2 +++ b/app/templates/main/index.html.j2 @@ -4,18 +4,57 @@ {% set roadmap = False %} {% block page_content %} +{% if current_user.is_anonymous %}
-

Lorem ipsum

+

No account?

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

+ person_addRegister
-
-

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

-
+
+
+ Log in + {{ login_form.hidden_tag() }} +
+ person + {{ login_form.user(class='validate') }} + {{ login_form.user.label }} + {% for error in login_form.user.errors %} + {{ error }} + {% endfor %} +
+
+ vpn_key + {{ login_form.password(class='validate') }} + {{ login_form.password.label }} + {% for error in login_form.password.errors %} + {{ error }} + {% endfor %} +
+
+ +
+
+ +
+
+
+
+
+ +
+
+{% endif %}

 

diff --git a/app/templates/nopaque.html.j2 b/app/templates/nopaque.html.j2 index fcefecc1..7320fe6c 100644 --- a/app/templates/nopaque.html.j2 +++ b/app/templates/nopaque.html.j2 @@ -51,7 +51,7 @@
  • settingsSettings
  • power_settings_newLog out
  • {% else %} -
  • personLog in
  • +
  • personLog in
  • person_addRegister
  • {% endif %} @@ -77,7 +77,7 @@
  • settingsSettings
  • power_settings_newLog out
  • {% else %} -
  • personLog in
  • +
  • personLog in
  • person_addRegister
  • {% endif %} {% if current_user.is_administrator() %} @@ -172,5 +172,23 @@ {% endfor %} }); + {% if not current_user.is_authenticated %} + + + {% endif %}