From aaf428575b4a64233164dcc7e0e4764c7a8a55d6 Mon Sep 17 00:00:00 2001 From: TuxCoder Date: Wed, 13 May 2020 20:08:28 +0200 Subject: [PATCH] fix not exist user --- lenticular_cloud/views/auth.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lenticular_cloud/views/auth.py b/lenticular_cloud/views/auth.py index b9326be..588fd5b 100644 --- a/lenticular_cloud/views/auth.py +++ b/lenticular_cloud/views/auth.py @@ -48,9 +48,13 @@ def login(): form = LoginForm() if form.validate_on_submit(): user = User.query().by_username(form.data['name']) - session['username'] = str(user.username) + if user: + session['username'] = str(user.username) + else: + session['user'] = None session['auth_providers'] = [] return redirect(url_for('auth.login_auth', next=flask.request.args.get('next'))) + return render_template('frontend/login.html.j2', form=form) @@ -78,8 +82,8 @@ def login_auth(): _host_url = urlparse(request.url) if _next_url.scheme == _host_url.scheme and _next_url.netloc == _host_url.netloc : _next = _next_url.geturl() - except Exception as e: - raise e + except TypeError: + _next = None return redirect(_next or url_for('frontend.index')) return render_template('frontend/login_auth.html.j2', forms=auth_forms)