logging users out Section 11, Lecture 51

layout.htmlに以下を追加で記述して、各ファンクションとリンクさせる。

<li><a href="{{ url_for('main.display_books') }}"> Home </a></li>
<li><a href="{{ url_for('authentication.register_user') }}"> Register </a></li>
<li> {% if current_user.is_authenticated %}
        <a href="{{ url_for('authentication.log_out_user') }}"> SignOut </a>
     {% else %}
        <a href="{{ url_for('authentication.do_the_login') }}"> SignIn </a>
     {% endif %}
</li>

ログアウト処理を作る。routes.pyに作る。 def log_out_user作って。リダイレクトさせるだけ

@at.route('/logout')
@login_required
def log_out_user():
    logout_user()
    flash('Logged out Successfully')
    return redirect(url_for('main.display_books'))

f:id:yukking3:20180506195344p:plain