Main page does not require login. Fixed login redirection

master
Davide Bongiovanni 6 years ago
parent 84f37a8780
commit 8abd54e9d2

@ -95,7 +95,6 @@ def addme():
return render_template('appresponse.html', message='Only one meal per person!') return render_template('appresponse.html', message='Only one meal per person!')
@app.route('/') @app.route('/')
@login_required
def index(): def index():
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals()) return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals())
@ -114,7 +113,7 @@ def login():
u = User.get(username) u = User.get(username)
u.user_id = result[0]['id'] u.user_id = result[0]['id']
login_user(u) login_user(u)
return redirect(request.args.get("next")) return redirect(request.args.get('next') or url_for('index'))
return abort(401) return abort(401)
else: else:
return Response(''' return Response('''

@ -46,10 +46,16 @@
{% endfor%} {% endfor%}
</div> </div>
<div class="user-card"> <div class="user-card">
{% if current_user.is_authenticated %}
<img src="{{url_for('static', filename=current_user.name + '.png')}}"> <img src="{{url_for('static', filename=current_user.name + '.png')}}">
{% endif %}
<div class="user-info"> <div class="user-info">
{% if current_user.is_authenticated %}
<span>{{current_user.name}}</span> <span>{{current_user.name}}</span>
<div class="rect-button" onclick="location.href='/logout';" style="background-color: #EE7500;">LOGOUT</div> <div class="rect-button" onclick="location.href='/logout';" style="background-color: #EE7500;">LOGOUT</div>
{% else %}
<div class="rect-button" onclick="location.href='/login';" style="background-color: #EE7500;">LOGIN</div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save