Link keycloak on profile page

This commit is contained in:
Tobias Kunze 2025-03-19 17:36:20 +01:00
parent c28fa71b9d
commit b11c7ecc21
2 changed files with 73 additions and 30 deletions

View file

@ -1,5 +1,5 @@
{% extends "frontend/base.html" %} {% extends "frontend/base.html" %}
{% load i18n %} {% load i18n static %}
{% block html_title %} {% block html_title %}
{% block page_title %} {% block page_title %}
{% translate "Profile" %} {% translate "Profile" %}
@ -10,32 +10,63 @@
<h4 class="card-title">{% translate "Account" %}</h4> <h4 class="card-title">{% translate "Account" %}</h4>
</div> </div>
{% endblock %} {% endblock %}
{% block card_content %} {% block content %}
<p> <section>
{% blocktranslate trimmed %} <div class="row match-height">
You are logged in with your VSHN user account. You will be able to change your password and other settings here in the future. <div class="col-md-6 col-12">
{% endblocktranslate %} <div class="card">
</p> <div class="card-header">
<div class="table-responsive"> <h4 class="card-title">{% translate "Profile" %}</h4>
<table class="table table-lg"> </div>
<tbody> <div class="card-content">
<tr> <div class="card-body">
<th>{% translate "E-mail" %}</th> <div class="table-responsive">
<td>{{ request.user.email }}</td> <table class="table table-lg">
</tr> <tbody>
<tr> <tr>
<th>{% translate "First name" %}</th> <th>{% translate "E-mail" %}</th>
<td>{{ request.user.first_name }}</td> <td>{{ request.user.email }}</td>
</tr> </tr>
<tr> <tr>
<th>{% translate "Last name" %}</th> <th>{% translate "First name" %}</th>
<td>{{ request.user.last_name }}</td> <td>{{ request.user.first_name }}</td>
</tr> </tr>
<tr> <tr>
<th>{% translate "Company" %}</th> <th>{% translate "Last name" %}</th>
<td>{{ request.user.company }}</td> <td>{{ request.user.last_name }}</td>
</tr> </tr>
</tbody> <tr>
</table> <th>{% translate "Company" %}</th>
</div> <td>{{ request.user.company }}</td>
{% endblock card_content %} </tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6 col-12">
<div class="card">
<div class="card-header">
<h4 class="card-title">{% translate "Account" %}</h4>
</div>
<div class="card-content">
<div class="card-body">
<p>
{% blocktranslate trimmed %}
You are logged in with your VSHN user account. Change your password and other account data here:
{% endblocktranslate %}
</p>
<a href="{{ account_href }}"
class="btn btn-warning btn-lg icon icon-left">
<img src="{% static 'img/keycloak.svg' %}" style="height: 30px">
<span class="mx-1">{% translate "VSHN Account" %}</span>
</a>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock content %}

View file

@ -1,3 +1,4 @@
from django.conf import settings
from django.views.generic import TemplateView from django.views.generic import TemplateView
@ -7,3 +8,14 @@ class IndexView(TemplateView):
class ProfileView(TemplateView): class ProfileView(TemplateView):
template_name = "frontend/profile.html" template_name = "frontend/profile.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
keycloak_server_url = settings.SOCIALACCOUNT_PROVIDERS["openid_connect"][
"APPS"
][0]["settings"]["server_url"]
account_url = keycloak_server_url.replace(
"/.well-known/openid-configuration", "/account"
)
context["account_href"] = account_url
return context