From 0d28c97f3155f77b284e6718f89fd20adacd7592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Fl=C3=BCckiger?= <91982622+JoFlucki@users.noreply.github.com> Date: Thu, 2 May 2024 16:08:42 +0200 Subject: [PATCH 01/13] Update deploy.rb --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 57022f6..f288b17 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -48,7 +48,6 @@ on roles(:app) do execute "ln -sf #{shared_path}/.env-api #{release_path}/api/.env" execute "ln -sf #{shared_path}/.env-frontend #{release_path}/frontend/.env" - execute "ln -sf #{shared_path}/.env-frontend #{release_path}/frontend/.env.production" end end @@ -86,6 +85,7 @@ on roles(:app) do within release_path.join('frontend') do execute :npm, 'install' # Installer les dépendances npm + execute :sudo, 'rm -rf dist' # Supprimer ancien build de l'application execute :npm, 'run build' # Construire l'application Vue.js end end From c93a8b6946b53669d1e5dd075b4483590f8dc35c Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 14:48:59 +0200 Subject: [PATCH 02/13] Redirect user to home after a logout --- frontend/src/components/NavBar.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/NavBar.vue b/frontend/src/components/NavBar.vue index 9817aec..2432947 100644 --- a/frontend/src/components/NavBar.vue +++ b/frontend/src/components/NavBar.vue @@ -1,5 +1,5 @@ From c0de289413f9fd6642968274353a115b99c2cb03 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 16:56:43 +0200 Subject: [PATCH 03/13] Add redirection after the logout --- frontend/src/components/NavBar.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/NavBar.vue b/frontend/src/components/NavBar.vue index 2432947..d1ce8f4 100644 --- a/frontend/src/components/NavBar.vue +++ b/frontend/src/components/NavBar.vue @@ -1,6 +1,9 @@ From f9d401d3d12a9b77c77d8ae50b2fc2a5d45fb1e2 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 17:09:58 +0200 Subject: [PATCH 04/13] Refresh the page after register/unregister to a tournament --- api/arconnectmanager/settings.py | 2 +- frontend/src/views/ManageTournamentsView.vue | 5 +++-- frontend/src/views/TournamentDetailsView.vue | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/arconnectmanager/settings.py b/api/arconnectmanager/settings.py index 283be2e..6d3dd6b 100644 --- a/api/arconnectmanager/settings.py +++ b/api/arconnectmanager/settings.py @@ -78,7 +78,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'allauth.account.middleware.AccountMiddleware', + #'allauth.account.middleware.AccountMiddleware', ] ROOT_URLCONF = 'arconnectmanager.urls' diff --git a/frontend/src/views/ManageTournamentsView.vue b/frontend/src/views/ManageTournamentsView.vue index f085da5..1fd4a64 100644 --- a/frontend/src/views/ManageTournamentsView.vue +++ b/frontend/src/views/ManageTournamentsView.vue @@ -46,7 +46,8 @@ onMounted(async () => {

Gérer les tournois - + add

@@ -67,7 +68,7 @@ onMounted(async () => {
+ title="Cliquez pour passer au prochain status"> next_plan { } await TournamentService.registerForTournament(tournamentId); } + + location.reload(); }; const unregister = async () => { @@ -36,6 +38,7 @@ const unregister = async () => { isRegistered.value = false; } await TournamentService.unregisterFromTournament(tournamentId); + location.reload(); }; From d8ee5115fc1acd4763a6a9fe2f889e5a86d8d3af Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 17:23:03 +0200 Subject: [PATCH 05/13] Add error message when log in failed --- frontend/src/views/LoginView.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index 241f646..95915ea 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -8,6 +8,7 @@ const form = ref(null) const username = ref(null) const password = ref(null) +const errorMessage = ref(null) const login = () => { if (!form.value.reportValidity()) return; @@ -16,7 +17,9 @@ const login = () => { password.value, ).then((token) => { router.push({ name: "home" }) - }) + }).catch(error => { + errorMessage.value = "Nom d'utilisateur ou mot de passe incorrect"; // Définition du message d'erreur + }); }; @@ -39,12 +42,16 @@ const login = () => {
+
{{ errorMessage }}

Pas de compte ? S'inscrire

\ No newline at end of file From 522c99da1856e9ea455e14c76c5613efbe416367 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 17:37:31 +0200 Subject: [PATCH 06/13] Add background to display of tournament --- frontend/src/views/TournamentDetailsView.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/TournamentDetailsView.vue b/frontend/src/views/TournamentDetailsView.vue index 5f736b2..8d48428 100644 --- a/frontend/src/views/TournamentDetailsView.vue +++ b/frontend/src/views/TournamentDetailsView.vue @@ -60,7 +60,7 @@ const unregister = async () => {
-
+
@@ -68,6 +68,9 @@ const unregister = async () => { \ No newline at end of file From 4fdaf9c58f9781ff668c5956af04827380813c54 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 19:04:52 +0200 Subject: [PATCH 07/13] Add loading animation --- frontend/src/views/ManageTournamentsView.vue | 37 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/ManageTournamentsView.vue b/frontend/src/views/ManageTournamentsView.vue index 1fd4a64..34c41e0 100644 --- a/frontend/src/views/ManageTournamentsView.vue +++ b/frontend/src/views/ManageTournamentsView.vue @@ -6,6 +6,8 @@ import { TournamentStatus } from '../domain/TournamentStatus'; const router = useRouter(); const tournaments = ref([]); +const loading = ref(false); + function deleteTournament(id,name) { let text = prompt("Êtes-vous sûr de vouloir supprimer le tournoi ?\nSi oui, tapez \"" + name + "\" pour confirmer"); @@ -30,9 +32,13 @@ function addTournament() { function nextTournamentStatus(tournament) { if (tournament.status.id == TournamentStatus.Completed.id) return; + loading.value = true; TournamentService.nextTournamentStatus(tournament).then((newStatus) => { const index = tournaments.value.indexOf(tournament); tournaments.value[index].status = newStatus; + loading.value = false; + }).catch(() => { + loading.value = false; }); } @@ -67,7 +73,7 @@ onMounted(async () => {
next_plan @@ -79,6 +85,8 @@ onMounted(async () => { title="Cliquez pour modifier le tournoi"> edit +
+

@@ -188,7 +196,7 @@ h1 { justify-content: center; align-items: center; border-radius: 1em; - background-color: #090909; +background-color: #090909; text-align: center; transition: all 0.25s ease-out; @@ -215,4 +223,29 @@ h1 { width: calc(100% - (3 * 8px / 4)); } } + +.loading-spinner { + border: 4px solid rgba(0, 0, 0, 0.1); + border-left-color: #09f; + border-radius: 50%; + width: 20%; + height: 100%; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} + +.disabled { + pointer-events: none; + opacity: 0.5; +} + \ No newline at end of file From 864a571664fd51d406772d4ac797e50c6d339b4c Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 19:25:11 +0200 Subject: [PATCH 08/13] Change icon when not enough player --- frontend/src/views/ManageTournamentsView.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/ManageTournamentsView.vue b/frontend/src/views/ManageTournamentsView.vue index 34c41e0..e294656 100644 --- a/frontend/src/views/ManageTournamentsView.vue +++ b/frontend/src/views/ManageTournamentsView.vue @@ -72,11 +72,17 @@ onMounted(async () => { {{ (tournament.status) }}
- - next_plan - + + delete From 198455ba1e7862c4f4e8dcf3fafd959ebc1c6409 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 19:25:47 +0200 Subject: [PATCH 09/13] small changes --- api/arconnectmanager/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/arconnectmanager/settings.py b/api/arconnectmanager/settings.py index 6d3dd6b..283be2e 100644 --- a/api/arconnectmanager/settings.py +++ b/api/arconnectmanager/settings.py @@ -78,7 +78,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - #'allauth.account.middleware.AccountMiddleware', + 'allauth.account.middleware.AccountMiddleware', ] ROOT_URLCONF = 'arconnectmanager.urls' From 4e10b24314335f4b10134831bf4c3dd97ee95934 Mon Sep 17 00:00:00 2001 From: Moreira Dos Santos Daniel Date: Thu, 2 May 2024 19:31:20 +0200 Subject: [PATCH 10/13] Add restriction to scores --- frontend/src/views/EditTournamentView.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/EditTournamentView.vue b/frontend/src/views/EditTournamentView.vue index d365879..de28ffc 100644 --- a/frontend/src/views/EditTournamentView.vue +++ b/frontend/src/views/EditTournamentView.vue @@ -81,13 +81,15 @@ const sendMatchResult = (match) => { + :value="match.scores === '' ? null : match.scores.split('-')[0]" + min="0" max="100"> + :value="match.scores === '' ? null : match.scores.split('-')[1]" + min="0" max="100"> From de658d0a310bc15b3041f854b57b5dc6252f5efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Fl=C3=BCckiger?= Date: Thu, 2 May 2024 19:42:09 +0200 Subject: [PATCH 11/13] Added pass hash --- frontend/src/domain/AuthService.js | 35 +++++++++++++++++++++++++---- frontend/src/views/LoginView.vue | 2 +- frontend/src/views/RegisterView.vue | 2 +- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/frontend/src/domain/AuthService.js b/frontend/src/domain/AuthService.js index ab71034..23743d9 100644 --- a/frontend/src/domain/AuthService.js +++ b/frontend/src/domain/AuthService.js @@ -3,7 +3,6 @@ import { ref } from 'vue'; import { setCookie, getCookie, deleteAllCookies } from "./Cookies"; import { User } from './User'; - /** Utility class to manage authentication and make requests to the API.*/ export class AuthService { @@ -17,10 +16,13 @@ export class AuthService { * @return {boolean} Wether the operation was successful. */ static async register(username, password, passwordConfirmation) { + const hash = await this.hashString(password); + const hashConf = await this.hashString(passwordConfirmation); + let data = { "username": username, - "password1": password, - "password2": passwordConfirmation, + "password1": hash, + "password2": hashConf, }; let response = null; @@ -46,11 +48,15 @@ export class AuthService { * @return {string} The authentication token that was saved. */ static async login(username, password) { + const hash = await this.hashString(password); + let data = { "username": username, - "password": password, + "password": hash, }; + + const response = await axios.post( `${import.meta.env.VITE_API_URL}/user/login/`, data @@ -113,6 +119,27 @@ export class AuthService { return null; } } + + + /** + * Hashes a string using the SHA-256 algorithm. + * @param {string} str - The string to be hashed. + * @returns {Promise} A Promise that resolves with the hexadecimal hash string. + */ + static async hashString(str) { + // Convert the string to an array buffer + const encoder = new TextEncoder(); + const data = encoder.encode(str); + + // Hash the data using SHA-256 algorithm + const hashBuffer = await crypto.subtle.digest('SHA-256', data); + + // Convert the hash buffer to a hex string + const hashArray = Array.from(new Uint8Array(hashBuffer)); + const hashHex = hashArray.map(byte => byte.toString(16).padStart(2, '0')).join(''); + + return hashHex; + } } diff --git a/frontend/src/views/LoginView.vue b/frontend/src/views/LoginView.vue index 95915ea..fecab06 100644 --- a/frontend/src/views/LoginView.vue +++ b/frontend/src/views/LoginView.vue @@ -32,7 +32,7 @@ const login = () => {
-
diff --git a/frontend/src/views/RegisterView.vue b/frontend/src/views/RegisterView.vue index dd68aa0..a9d1420 100644 --- a/frontend/src/views/RegisterView.vue +++ b/frontend/src/views/RegisterView.vue @@ -35,7 +35,7 @@ const register = async () => {
-
From a9dcdab39ede3a55e2c461cf397ec2f0ec54b500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Fl=C3=BCckiger?= Date: Thu, 2 May 2024 19:57:59 +0200 Subject: [PATCH 12/13] Highlighted button --- frontend/src/views/ManageTournamentsView.vue | 41 +++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/frontend/src/views/ManageTournamentsView.vue b/frontend/src/views/ManageTournamentsView.vue index e294656..076e7a1 100644 --- a/frontend/src/views/ManageTournamentsView.vue +++ b/frontend/src/views/ManageTournamentsView.vue @@ -9,17 +9,17 @@ const tournaments = ref([]); const loading = ref(false); -function deleteTournament(id,name) { +function deleteTournament(id, name) { let text = prompt("Êtes-vous sûr de vouloir supprimer le tournoi ?\nSi oui, tapez \"" + name + "\" pour confirmer"); - if(text ==name){ - + if (text == name) { + TournamentService.deleteTournament(id).then((successful) => { if (!successful) return; tournaments.value = tournaments.value.filter((tournament) => tournament.id != id); - }); + }); } - + } function editTournament(id) { @@ -32,13 +32,13 @@ function addTournament() { function nextTournamentStatus(tournament) { if (tournament.status.id == TournamentStatus.Completed.id) return; - loading.value = true; + loading.value = true; TournamentService.nextTournamentStatus(tournament).then((newStatus) => { const index = tournaments.value.indexOf(tournament); tournaments.value[index].status = newStatus; - loading.value = false; + loading.value = false; }).catch(() => { - loading.value = false; + loading.value = false; }); } @@ -52,8 +52,7 @@ onMounted(async () => {

Gérer les tournois - + add

@@ -78,8 +77,7 @@ onMounted(async () => { title="Cliquez pour passer au prochain statut">next_plan @@ -112,6 +110,20 @@ h1 { span { cursor: pointer; margin-left: 16px; + border-width: 1px; + border-color: white; + background: white; + border-style: solid; + padding: 4px; + border-radius: 4px; + color: black; + transition: all 0.25s; + + + &:hover { + transform: translateY(-2px); + box-shadow: 0px 0px 20px rgba($color: $primary, $alpha: 0.5); + } } } @@ -202,7 +214,7 @@ h1 { justify-content: center; align-items: center; border-radius: 1em; -background-color: #090909; + background-color: #090909; text-align: center; transition: all 0.25s ease-out; @@ -250,8 +262,7 @@ background-color: #090909; } .disabled { - pointer-events: none; + pointer-events: none; opacity: 0.5; } - \ No newline at end of file From f47ad2d865b8d5f714f88032f5b9a34740dfe901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Fl=C3=BCckiger?= Date: Thu, 2 May 2024 20:05:13 +0200 Subject: [PATCH 13/13] Added "not allowed" cursor --- frontend/src/views/ManageTournamentsView.vue | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/frontend/src/views/ManageTournamentsView.vue b/frontend/src/views/ManageTournamentsView.vue index 076e7a1..9a4d9ac 100644 --- a/frontend/src/views/ManageTournamentsView.vue +++ b/frontend/src/views/ManageTournamentsView.vue @@ -71,16 +71,14 @@ onMounted(async () => { {{ (tournament.status) }}
- - + + next_plan + + cancel + delete @@ -181,12 +179,19 @@ h1 { user-select: none; /* Standard syntax */ - span:hover { - cursor: pointer; - } + span { + &:hover { + cursor: pointer; + } - span.disabled:hover { - cursor: not-allowed; + &.disabled { + opacity: 0.5; + + &:hover { + + cursor: not-allowed; + } + } } } @@ -260,9 +265,4 @@ h1 { transform: rotate(360deg); } } - -.disabled { - pointer-events: none; - opacity: 0.5; -} \ No newline at end of file