Skip to content

Commit 0f30e4d

Browse files
committed
update password modification
1 parent 2381f4b commit 0f30e4d

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

react-frontend/src/api/users/UserEmailDataService.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import axios from "axios";
22

33
const UserEmailDataService = async (email) => {
44
try {
5-
return axios.post(`http://localhost:8080/notification`, email);
5+
return axios.post(`http://localhost:8080/notification`, null, {
6+
params: {
7+
email,
8+
},
9+
});
610
} catch (err) {
711
let error = "";
812
if (err.response) {

react-frontend/src/components/root/users/login/forgottenPassword/PasswordChange.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { useState } from "react";
55
import styles from "../../../../../css/Forms.module.css";
66
import style from "../../../../../css/Footer.module.css";
77
import UserEmailDataService from "../../../../../api/users/UserEmailDataService";
8+
import LoadingDotsDark from "../animation/LoadingDotsDark";
89

910
const PasswordChange = () => {
1011
const [email, setEmail] = useState("");
12+
const [loading, setLoading] = useState(false);
1113
const [sent, setSent] = useState(false);
1214
const [found, setFound] = useState(true);
1315
const [errors, setErrors] = useState({});
@@ -29,13 +31,15 @@ const PasswordChange = () => {
2931
console.log(errors);
3032

3133
if (Object.keys(errors).length === 0) {
34+
setLoading(true);
3235
const res = await UserEmailDataService(email);
3336
console.log(res.status);
3437

3538
if (res.status === 200) {
3639
setSent(true);
3740
setFound(true);
3841
} else {
42+
setLoading(false);
3943
setFound(false);
4044
}
4145
}
@@ -77,9 +81,13 @@ const PasswordChange = () => {
7781
</label>
7882
</section>
7983
</div>
80-
<button className={styles.button} onClick={sentClicked}>
81-
Submit
82-
</button>
84+
{loading && <LoadingDotsDark className={styles.dots} />}
85+
86+
{!loading && (
87+
<button className={styles.button} onClick={sentClicked}>
88+
Submit
89+
</button>
90+
)}
8391
</div>
8492
)}
8593
{sent && (

spring-backend/src/main/java/backend/hobbiebackend/web/UserController.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import java.io.UnsupportedEncodingException;
3030
import java.net.URLDecoder;
31-
31+
import java.nio.charset.StandardCharsets;
3232

3333

3434
@RestController
@@ -110,10 +110,8 @@ public ResponseEntity<?> updateUser(@RequestBody UpdateAppClientDto user) {
110110

111111
}
112112
@PostMapping ("/notification")
113-
public ResponseEntity<?> sendNotification(@RequestBody String e) throws UnsupportedEncodingException {
114-
String email = URLDecoder.decode(e, "UTF-8");
115-
email = email.substring(0, email.length()-1);
116-
UserEntity userByEmail = this.userService.findUserByEmail(email);
113+
public ResponseEntity<?> sendNotification(@RequestParam("email") String e) {
114+
UserEntity userByEmail = this.userService.findUserByEmail(e);
117115

118116
if(userByEmail == null){
119117
throw new NotFoundException("User not found");

0 commit comments

Comments
 (0)