odhlašování

This commit is contained in:
Martin Quarda 2024-10-09 23:45:03 +02:00
parent ccf234444b
commit 1eeba8ec14
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.template.response import TemplateResponse from django.template.response import TemplateResponse
from django.shortcuts import redirect
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.models import User as DjangoUser from django.contrib.auth.models import User as DjangoUser
@ -64,6 +65,7 @@ def login(request):
@csrf_exempt @csrf_exempt
def logout(request): def logout(request):
auth_logout(request) auth_logout(request)
return redirect("/#")
@csrf_exempt @csrf_exempt

View File

@ -169,6 +169,11 @@ class Main extends Component {
<a class="nav-link" href="#login">Přihlašování</a> <a class="nav-link" href="#login">Přihlašování</a>
</li> </li>
} }
{Object.keys(this.state.login_status) &&
<li>
Přihlášen {this.state.login_status.first_name} {this.state.login_status.last_name} <a href="/api/logout">Odhlásit</a>
</li>
}
</ul> </ul>
</div> </div>
</nav> </nav>