Log out
This commit is contained in:
parent
ba8bade697
commit
152bd67c70
5 changed files with 33 additions and 2 deletions
|
@ -315,5 +315,13 @@ def student_data(request, *args, **kwargs):
|
|||
s = decrypt_cookies(s, key)
|
||||
data = get_student_data(register_id, register_r, oun, s)
|
||||
return JsonResponse(data)
|
||||
else:
|
||||
return redirect('../')
|
||||
|
||||
def log_out(request, *args, **kwargs):
|
||||
if request.session.has_key('is_logged'):
|
||||
del request.session[request.session.session_key]
|
||||
del request.session['is_logged']
|
||||
return JsonResponse({'logOut': True})
|
||||
else:
|
||||
return redirect('../')
|
|
@ -75,4 +75,5 @@ body {
|
|||
float: right;
|
||||
margin-right: 10px;
|
||||
color: blue;
|
||||
cursor: pointer;
|
||||
}
|
20
frontend/static/frontend/js/log-out.js
Normal file
20
frontend/static/frontend/js/log-out.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
const log_out_ = document.querySelector('#log_out_');
|
||||
|
||||
myStorage = window.sessionStorage;
|
||||
|
||||
const logOut = () => {
|
||||
fetch(url = '../api/log_out', {
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': csrfcookie_
|
||||
}
|
||||
}).then(response => response.json()).then(data => {
|
||||
sessionStorage.clear();
|
||||
console.log(data)
|
||||
window.location.href = '../'
|
||||
})
|
||||
}
|
||||
|
||||
log_out_.addEventListener('click', logOut)
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<div class="gradeModals"></div> <!-- please don't touch it for scraping, you have an api :D -->
|
||||
|
||||
<nav>Wulkanowy web early access insider preview pre-alpha pre-beta alpha beta release canditate v. 0.0.1<a class='log-out' href='../'>Wyloguj</a></nav>
|
||||
<nav>Wulkanowy web early access insider preview pre-alpha pre-beta alpha beta release canditate v. 0.0.1<div id='log_out_' class='log-out'>Wyloguj</div></nav>
|
||||
|
||||
<ul id="slide-out" class="sidenav">
|
||||
<li><div class="user-view">
|
||||
|
@ -93,5 +93,6 @@
|
|||
<script src="{% static 'frontend/js/mobile_access.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'frontend/js/school_data.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'frontend/js/student_data.js' %}" type="text/javascript" defer></script>
|
||||
<script src="{% static 'frontend/js/log-out.js' %}" type="text/javascript" defer></script>
|
||||
</body>
|
||||
</html>
|
|
@ -17,7 +17,7 @@ from django.urls import path
|
|||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
from frontend.views import default_view, content_view, account_manager_view
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send, message_content, student_data
|
||||
from app.views import login, grades, timetable, exams, homeworks, attendance, notes, registered_devices, register_device_, received_messages, sent_messages, deleted_messages, school_data, dashboard, recipients, send, message_content, student_data, log_out
|
||||
|
||||
urlpatterns = [
|
||||
#views
|
||||
|
@ -35,6 +35,7 @@ urlpatterns = [
|
|||
path('api/school_data', school_data, name='school_data'),
|
||||
path('api/dashboard', dashboard, name='dashboard'),
|
||||
path('api/student_data', student_data, name='student_data'),
|
||||
path('api/log_out', log_out, name='log_out'),
|
||||
#MOBILE ACCESS
|
||||
path('api/mobile/registered', registered_devices, name='registered_devices'),
|
||||
path('api/mobile/register', register_device_, name='register_device'),
|
||||
|
|
Loading…
Reference in a new issue