Create logout view
This commit is contained in:
parent
734cd8e6e5
commit
43b5a67cab
|
@ -185,7 +185,7 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item d-flex align-items-center" href="users-profile.html">
|
<a class="dropdown-item d-flex align-items-center" href="{{ url_for('core.user-profile') }}">
|
||||||
<i class="bi bi-person"></i>
|
<i class="bi bi-person"></i>
|
||||||
<span>My Profile</span>
|
<span>My Profile</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -194,16 +194,6 @@
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
|
||||||
<a class="dropdown-item d-flex align-items-center" href="users-profile.html">
|
|
||||||
<i class="bi bi-gear"></i>
|
|
||||||
<span>Account Settings</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<hr class="dropdown-divider">
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item d-flex align-items-center" href="pages-faq.html">
|
<a class="dropdown-item d-flex align-items-center" href="pages-faq.html">
|
||||||
<i class="bi bi-question-circle"></i>
|
<i class="bi bi-question-circle"></i>
|
||||||
|
@ -215,7 +205,7 @@
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item d-flex align-items-center" href="#">
|
<a class="dropdown-item d-flex align-items-center" href="{{ url_for('core.logout') }}">
|
||||||
<i class="bi bi-box-arrow-right"></i>
|
<i class="bi bi-box-arrow-right"></i>
|
||||||
<span>Sign Out</span>
|
<span>Sign Out</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import flask
|
import flask
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask.views import View
|
from flask.views import View
|
||||||
from flask_login import login_required, login_user
|
from flask_login import login_required, login_user, logout_user
|
||||||
|
|
||||||
from ereuse_devicehub.forms import LoginForm
|
from ereuse_devicehub.forms import LoginForm
|
||||||
from ereuse_devicehub.resources.user.models import User
|
from ereuse_devicehub.resources.user.models import User
|
||||||
|
@ -32,6 +32,12 @@ class LoginView(View):
|
||||||
return flask.render_template('ereuse_devicehub/user_login.html', form=form)
|
return flask.render_template('ereuse_devicehub/user_login.html', form=form)
|
||||||
|
|
||||||
|
|
||||||
|
class LogoutView(View):
|
||||||
|
def dispatch_request(self):
|
||||||
|
logout_user()
|
||||||
|
return flask.redirect(flask.url_for('core.login'))
|
||||||
|
|
||||||
|
|
||||||
class UserProfileView(View):
|
class UserProfileView(View):
|
||||||
decorators = [login_required]
|
decorators = [login_required]
|
||||||
template_name = 'ereuse_devicehub/user_profile.html'
|
template_name = 'ereuse_devicehub/user_profile.html'
|
||||||
|
@ -42,4 +48,5 @@ class UserProfileView(View):
|
||||||
|
|
||||||
|
|
||||||
core.add_url_rule('/login/', view_func=LoginView.as_view('login'))
|
core.add_url_rule('/login/', view_func=LoginView.as_view('login'))
|
||||||
|
core.add_url_rule('/logout/', view_func=LogoutView.as_view('logout'))
|
||||||
core.add_url_rule('/profile/', view_func=UserProfileView.as_view('user-profile'))
|
core.add_url_rule('/profile/', view_func=UserProfileView.as_view('user-profile'))
|
||||||
|
|
Reference in New Issue