Skip to content

Commit 2a259e8

Browse files
committed
[FIX] login/register issues
1 parent 1d66539 commit 2a259e8

File tree

9 files changed

+63
-49
lines changed

9 files changed

+63
-49
lines changed
-432 Bytes
Binary file not shown.

html/assets/js/dashboard/my_onload.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
async function my_onload() {
99
const username = document.getElementById("username_field");
1010
// const dropdown_header_widget = document.getElementById("header_dropdown");
11-
const widget_field = document.getElementById("widgets_body");
11+
// const widget_field = document.getElementById("widgets_body");
1212

1313
await update_username(username);
1414
// await get_widgets_options(dropdown_header_widget);
15-
await inject_widgets(widget_field);
16-
await get_refresh_delay('refresh_delay');
17-
refresh_widgets(widget_field);
15+
// await inject_widgets(widget_field);
16+
// await get_refresh_delay('refresh_delay');
17+
// refresh_widgets(widget_field);
1818
}
1919

2020
// Add a a rule to only run once the page is loaded

html/assets/js/login/initializer.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,43 @@
66
*/
77

88
function inject_submit_actions() {
9+
const formId = "loginForm";
10+
const registerFormId = "registerForm";
911
const personal = "submit";
1012
const professional = "submit_professional";
11-
if (document.getElementById("loginForm") === null) {
13+
const elementFormId = document.getElementById(formId);
14+
const elementRegisterFormId = document.getElementById(registerFormId);
15+
16+
if (elementFormId === null) {
1217
console.error("No login form found");
1318
return;
1419
}
15-
if (document.getElementById("registerForm") === null) {
20+
if (elementRegisterFormId === null) {
1621
console.error("No register form found");
1722
return;
1823
}
19-
if (document.getElementById("loginForm").querySelector(`input[type="${personal}"]`)) {
24+
25+
if (elementFormId.querySelector(`button[type="${personal}"]`)) {
2026
console.log(`Found ${personal} button`);
21-
document.getElementById("loginForm").addEventListener(personal, function (event) {
27+
elementFormId.addEventListener(personal, function (event) {
2228
event.preventDefault();
2329
log_user_in();
2430
});
25-
document.getElementById("registerForm").addEventListener(personal, function (event) {
31+
elementRegisterFormId.addEventListener(personal, function (event) {
2632
event.preventDefault();
2733
register_user();
2834
});
29-
} else if (document.getElementById("loginForm").querySelector(`input[type="${professional}"]`)) {
35+
} else if (elementFormId.querySelector(`button[type="${professional}"]`)) {
3036
console.log(`Found ${professional} button`);
31-
document.getElementById("loginForm").addEventListener(professional, function (event) {
37+
elementFormId.addEventListener(professional, async function (event) {
3238
event.preventDefault();
3339
log_user_in_professional();
3440
});
35-
document.getElementById("registerForm").addEventListener(professional, function (event) {
41+
elementRegisterFormId.addEventListener(professional, async function (event) {
3642
event.preventDefault();
3743
register_user_professional();
3844
});
45+
console.log(`${professional} button found and added event listener`);
3946
} else {
4047
console.error("No submit button found");
4148
}

html/assets/js/login/log_user_in.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,47 @@ async function log_user_in() {
1010
const email = document.getElementById("loginEmail").value;
1111
const password = document.getElementById("loginPassword").value;
1212

13+
console.log("window.location", window.location);
14+
console.log("window.location.href", window.location.href);
15+
console.log("window.location.origin", window.location.origin);
16+
console.log("window.location.host", window.location.host);
17+
console.log("window.location.hostname", window.location.hostname);
18+
console.log("window.location.protocol", window.location.protocol);
19+
console.log("window.location.port", window.location.port);
20+
console.log("window.location.search", window.location.search);
21+
console.log("window.location.hash", window.location.hash);
22+
console.log("window.location.pathname", window.location.pathname);
23+
console.log("dashboard", dashboard);
24+
1325
const response = await window.update_server.login(email, password);
1426

1527
console.log(`login: JSON response: ${JSON.stringify(response)}`);
1628

1729
if (response.ok) {
1830
console.log("Login successful:", response);
1931
// window.location.pathname = window.constants.dashboard_page;
20-
console.log("window.location", window.location);
21-
console.log("window.location.href", window.location.href);
22-
console.log("window.location.origin", window.location.origin);
23-
console.log("window.location.host", window.location.host);
24-
console.log("window.location.hostname", window.location.hostname);
25-
console.log("window.location.protocol", window.location.protocol);
26-
console.log("window.location.port", window.location.port);
27-
console.log("window.location.search", window.location.search);
28-
console.log("window.location.hash", window.location.hash);
29-
console.log("window.location.pathname", window.location.pathname);
30-
console.log("dashboard", dashboard);
31-
await sleep(5000);
32-
3332
window.location.pathname = dashboard;
3433
} else {
3534
update_error_message("Login failed: " + response.message);
36-
await sleep(5000);
3735
}
3836
}
3937

4038
async function log_user_in_professional() {
39+
const suivi = "/routes/pro/suivi";
4140
const email = document.getElementById("loginEmail").value;
4241
const password = document.getElementById("loginPassword").value;
4342

43+
console.log("window.location", window.location);
44+
console.log("suivi: ", suivi);
45+
4446
const response = await window.update_server.login_professional(email, password);
4547

4648
console.log(`login: JSON response: ${JSON.stringify(response)}`);
4749

4850
if (response.ok) {
4951
console.log("Login successful:", response);
5052
// window.location.pathname = window.constants.dashboard_page;
51-
window.location.pathname = "/dashboard/pro/suivi";
53+
window.location.pathname = suivi;
5254
} else {
5355
update_error_message("Login failed: " + response.message);
5456
}

html/assets/js/login/register_user.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@
66
*/
77

88
async function register_user() {
9+
const dashboard = "/routes/user/dashboard";
910
const username = document.getElementById("registerUsername").value;
1011
const email = document.getElementById("registerEmail").value;
1112
const password = document.getElementById("registerPassword").value;
1213
const password_confirmation = document.getElementById("registerPasswordConfirmation").value;
1314

15+
console.log("window.location", window.location);
16+
console.log("window.location.href", window.location.href);
17+
console.log("window.location.origin", window.location.origin);
18+
console.log("window.location.host", window.location.host);
19+
console.log("window.location.hostname", window.location.hostname);
20+
console.log("window.location.protocol", window.location.protocol);
21+
console.log("window.location.port", window.location.port);
22+
console.log("window.location.search", window.location.search);
23+
console.log("window.location.hash", window.location.hash);
24+
console.log("window.location.pathname", window.location.pathname);
25+
console.log("dashboard", dashboard);
26+
1427
if (password !== password_confirmation) {
1528
update_error_message("Passwords do not match !");
1629
return;
@@ -24,31 +37,37 @@ async function register_user() {
2437

2538
if (response.ok) {
2639
console.log("Registration successful:", response);
27-
window.location.href = window.constants.dashboard_page;
40+
// window.location.href = window.constants.dashboard_page;
41+
window.location.pathname = dashboard;
2842
} else {
2943
update_error_message("Registration failed: " + response.message);
3044
}
3145
}
3246
async function register_user_professional() {
47+
const suivi = "/routes/pro/suivi";
3348
const username = document.getElementById("registerUsername").value;
3449
const email = document.getElementById("registerEmail").value;
3550
const password = document.getElementById("registerPassword").value;
3651
const password_confirmation = document.getElementById("registerPasswordConfirmation").value;
3752

53+
console.log("window.location", window.location);
54+
console.log("suivi: ", suivi);
55+
3856
if (password !== password_confirmation) {
3957
update_error_message("Passwords do not match !");
4058
return;
4159
}
4260

4361
console.log("passwords match");
4462

45-
const response = await window.update_server.register(username, email, password);
63+
const response = await window.update_server.register_professional(username, email, password);
4664

4765
console.log(`register: JSON response: ${JSON.stringify(response)}`);
4866

4967
if (response.ok) {
5068
console.log("Registration successful:", response);
51-
window.location.href = window.constants.dashboard_page;
69+
// window.location.pathname = window.constants.dashboard_page;
70+
window.location.pathname = suivi;
5271
} else {
5372
update_error_message("Registration failed: " + response.message);
5473
}

html/assets/js/modules/manage_server.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function register(username, email, password) {
1515
console.log("password:", password);
1616
// let response = await window.querier.post("/register", { username, email, password });
1717
alert("Il s'agit d'un site de démonstration, votre compte n'existera que localement sur votre ordinateur. Vous pouvez utiliser l'adresse e-mail et le mot de passe de votre choix.");
18-
let response = { "ok": true, "resp": { "id": 1, "token": "Not a token", "username": email.split("@")[0] } };
18+
let response = { "ok": true, "resp": { "id": 1, "token": "Not a token", "username": username } };
1919
console.log("response:", response);
2020
console.log(`(register, before response) JSON response: ${JSON.stringify(response)}`);
2121
if (response.ok) {

html/professional.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@
138138
<p id="error_message">Hello world !</p>
139139
<aside class="form-container">
140140
<form id="loginForm">
141-
<h2>Login</h2><input type="email" id="loginEmail" placeholder="Email" required=""><input type="password" id="loginPassword" placeholder="Password" required=""><button type="submit_professional">Login</button>
141+
<h2>Login</h2><input type="email" id="loginEmail" placeholder="Email" required=""><input type="password" id="loginPassword" placeholder="Password" required=""><button type="submit_professional" onclick="event.preventDefault();log_user_in_professional();">Login</button>
142142
<div class="reset_password"><a href="./reset-password">Mot de passe oublié ?</a></div>
143143
</form>
144144
<form id="registerForm">
145-
<h2>Register</h2><input type="text" id="registerUsername" placeholder="Username" required=""><input type="email" id="registerEmail" placeholder="Email" required=""><input type="password" id="registerPassword" placeholder="Password" required=""><input type="password" id="registerPasswordConfirmation" placeholder="Confirm Password" required=""><button type="submit">Register</button>
145+
<h2>Register</h2><input type="text" id="registerUsername" placeholder="Username" required=""><input type="email" id="registerEmail" placeholder="Email" required=""><input type="password" id="registerPassword" placeholder="Password" required=""><input type="password" id="registerPasswordConfirmation" placeholder="Confirm Password" required=""><button type="submit_professional" onclick="event.preventDefault();register_user_professional();">Register</button>
146146
</form>
147147
</aside>
148148
<aside class="sso_separator_box">

html/reset-password/index.html

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,31 +124,20 @@
124124

125125
<body>
126126
<main class="login_register_box">
127+
<p style="background-color:yellow;color:black;">Ceci est un site de <strong>démonstration</strong>, vos données personnelles ne seront enregistré que sur votre ordinateur. Quel que soit l'e-mail <strong>et/ou</strong> le mot de passe la connexion <strong>fonctionnera</strong>.<br>Le boutton <strong>FranceConnect</strong>&nbsp;n'aura aucun effet, il est présent pour indiquer une fonctionnalité <strong>à venir</strong>.</p>
127128
<section><select id="fontSelector"></select>
128129
<div class="theme-switcher dropdown" id="themeToggler"><button class="btn btn-link dropdown-toggle" aria-expanded="false" data-bs-toggle="dropdown" style="color:var(--bs-body-color);" type="button"><svg class="bi bi-sun-fill mb-1" fill="currentColor" height="1em" viewbox="0 0 16 16" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path></svg></button>
129130
<div class="dropdown-menu"><a class="dropdown-item d-flex align-items-center" data-bs-theme-value="light" href="#"><svg class="bi bi-sun-fill opacity-50 me-2" fill="currentColor" height="1em" viewbox="0 0 16 16" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z"></path></svg>Light </a><a class="dropdown-item d-flex align-items-center" data-bs-theme-value="dark" href="#"><svg class="bi bi-moon-stars-fill opacity-50 me-2" fill="currentColor" height="1em" viewbox="0 0 16 16" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278"></path><path d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.734 1.734 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.734 1.734 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.734 1.734 0 0 0 1.097-1.097l.387-1.162zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z"></path></svg>Dark </a><a class="dropdown-item d-flex align-items-center" data-bs-theme-value="auto" href="#"><svg class="bi bi-circle-half opacity-50 me-2" fill="currentColor" height="1em" viewbox="0 0 16 16" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M8 15A7 7 0 1 0 8 1zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16"></path></svg>Auto </a></div>
130131
</div>
131132
</section>
132133
<section class="my_container">
133-
<p>Pour les professionels c'est <a href="../professional.html">ici</a></p>
134-
<section class="toggle-container"><span>Connection</span><label class="switch"><input type="checkbox" id="toggleSwitch"><span class="slider round"></span></label><span>Inscription</span></section>
135134
<section class="form-wrapper">
136135
<p id="error_message">Hello world !</p>
137136
<aside class="form-container">
138-
<form id="loginForm">
139-
<h2>Login</h2><input type="email" id="loginEmail" placeholder="Email" required=""><input type="password" id="loginPassword" placeholder="Password" required=""><button type="submit">Connection</button>
140-
<div class="reset_password"><a href="./reset-password">Mot de passe oublié ?</a></div>
141-
</form>
142137
<form id="registerForm">
143-
<h2>Register</h2><input type="text" id="registerUsername" placeholder="Username" required=""><input type="email" id="registerEmail" placeholder="Email" required=""><input type="password" id="registerPassword" placeholder="Password" required=""><input type="password" id="registerPasswordConfirmation" placeholder="Confirm Password" required=""><button type="submit">Register</button>
138+
<h2>Réanitialiser mon mot de passe</h2><input type="password" id="registerPassword" placeholder="Mot de passe" required=""><input type="password" id="registerPasswordConfirmation" placeholder="Confirmer mot de passe" required=""><button type="submit" onclick="event.preventDefault();window.location.pathname = &quot;/&quot;">Mettre à jour</button>
144139
</form>
145140
</aside>
146-
<aside class="sso_separator_box">
147-
<hr class="sso_separator">
148-
<p class="sso_text">ou</p>
149-
<hr class="sso_separator">
150-
</aside>
151-
<aside><button class="sso_button_france_connect" type="submit"><img src="../assets/img/france-connect-cropped.png"></button></aside>
152141
</section>
153142
</section>
154143
</main>

html/sitemap.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
<url>
3131
<loc>https://asperboard.pingpal.news/routes/user/suivi/</loc>
3232
</url>
33-
<url>
34-
<loc>https://asperboard.pingpal.news/routes/</loc>
35-
</url>
3633
<url>
3734
<loc>https://asperboard.pingpal.news/</loc>
3835
</url>

0 commit comments

Comments
 (0)