Implement OAuth login with Authentik integration, update user management, and enhance team functionalities

- Added OAuth login functionality using Authentik, allowing users to log in via OpenID.
- Updated user registration and login processes to handle OAuth users.
- Enhanced team management features, including joining and leaving teams, and displaying user-specific team information.
- Improved error handling and user feedback for team actions.
- Added new database migrations for OAuth-related fields in the users table.
- Updated templates to reflect changes in user authentication and team management.
- Refactored dashboard and leaderboard views to include user context and team memberships.
This commit is contained in:
Christian Krakau-Louis
2025-04-14 05:35:51 +02:00
parent fa41b24eac
commit 690065f788
15 changed files with 938 additions and 139 deletions
+55 -23
View File
@@ -16,9 +16,21 @@
</div>
</div>
<div>
<button class="bg-white text-irish-green font-medium py-2 px-4 rounded-md hover:bg-opacity-90">
<i class="fas fa-share-alt mr-1"></i> Share Team
</button>
{% if not user %}
<a href="/auth/login?next=/teams/{{ team.id }}" class="bg-white text-irish-green font-medium py-2 px-4 rounded-md hover:bg-opacity-90">
Login to Join
</a>
{% elif not is_team_member %}
<form action="/teams/join/{{ team.id }}" method="post" class="inline">
<button type="submit" class="bg-white text-irish-green font-medium py-2 px-4 rounded-md hover:bg-opacity-90">
Join Team
</button>
</form>
{% else %}
<button class="bg-white text-irish-green font-medium py-2 px-4 rounded-md hover:bg-opacity-90">
<i class="fas fa-share-alt mr-1"></i> Share Team
</button>
{% endif %}
</div>
</div>
</div>
@@ -156,34 +168,54 @@
</div>
<!-- Team Management -->
{% if is_user_admin %}
<div class="bg-white rounded-lg shadow-md p-6">
<h2 class="text-xl font-semibold text-irish-green mb-4">Team Management</h2>
<div class="space-y-6">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Team Name</label>
<div class="flex">
<input type="text" value="{{ team.name }}" class="flex-grow border border-gray-300 rounded-l-md px-3 py-2" {% if not is_user_admin %}disabled{% endif %}>
<button class="bg-irish-green text-white px-4 py-2 rounded-r-md" {% if not is_user_admin %}disabled{% endif %}>Save</button>
{% if is_user_owner %}
<div class="bg-irish-green bg-opacity-10 p-3 rounded-md mb-4">
<p class="text-irish-green font-medium">You are the owner of this team</p>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Team Privacy</label>
<div class="flex items-center">
<input type="checkbox" id="public-team" name="is_public" class="mr-2"
{% if team.is_public %}checked{% endif %}
{% if not is_user_admin %}disabled{% endif %}>
<label for="public-team">Make team publicly joinable (no invitation needed)</label>
{% elif is_user_admin %}
<div class="bg-golden-ale bg-opacity-10 p-3 rounded-md mb-4">
<p class="text-golden-ale font-medium">You are an admin of this team</p>
</div>
</div>
{% endif %}
<div class="pt-4 border-t">
<button class="bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded-md">
Leave Team
</button>
</div>
<form action="/teams/{{ team.id }}/update" method="post">
<div class="mb-4">
<label for="team_name" class="block text-sm font-medium text-gray-700 mb-2">Team Name</label>
<div class="flex">
<input type="text" id="team_name" name="team_name" value="{{ team.name }}" class="flex-grow border border-gray-300 rounded-l-md px-3 py-2">
<button type="submit" class="bg-irish-green text-white px-4 py-2 rounded-r-md">Save</button>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Team Privacy</label>
<div class="flex items-center">
<input type="checkbox" id="is_public" name="is_public" class="mr-2"
{% if team.is_public %}checked{% endif %}>
<label for="is_public">Make team publicly joinable (no invitation needed)</label>
</div>
</div>
</form>
</div>
</div>
{% endif %}
<!-- Leave team option - only for members -->
{% if is_team_member and not is_user_owner %}
<div class="bg-white rounded-lg shadow-md p-6 mt-6">
<h2 class="text-xl font-semibold text-irish-green mb-4">Team Membership</h2>
<p class="mb-4">You are currently a member of this team.</p>
<form action="/teams/{{ team.id }}/leave" method="post">
<button type="submit" class="bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded-md">
Leave Team
</button>
</form>
</div>
{% endif %}
</div>
{% endblock %}