Skip to content

Commit

Permalink
update Forgot password to match other requests
Browse files Browse the repository at this point in the history
  • Loading branch information
avsomers25 committed Aug 28, 2023
1 parent ed009e7 commit 477ad89
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
23 changes: 11 additions & 12 deletions src/components/Forgot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,22 @@ const ForgotPage = (props) => {
const [done, setDone] = useState(false);
const [errors, setErrors] = useState("");

const onSubmit = (e) => {
const onSubmit = async (e) => {
e.preventDefault();
if (!loading) {
setLoading(true);
setErrors("");
let email = document.getElementById("email").value;
props.profile.Forgot(email)
.then((msg) => {
if (msg.error) {
setLoading(false);
setErrors(msg.error);
} else {
setLoading(false);
setDone(true);
setErrors("");
}
});
let msg = await props.profile.Forgot(email)

Check failure on line 51 in src/components/Forgot.jsx

View workflow job for this annotation

GitHub Actions / build (12.x)

Missing semicolon
if (msg.error) {
setLoading(false);
setErrors(msg.error);
} else {
setLoading(false);
setDone(true);
setErrors("");
}

}
};

Expand Down
24 changes: 12 additions & 12 deletions src/components/Profile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ControlCameraSharp } from "@material-ui/icons";

Check failure on line 1 in src/components/Profile.js

View workflow job for this annotation

GitHub Actions / build (12.x)

'ControlCameraSharp' is defined but never used
import { defaults } from "../Defaults";
import PropTypes from "prop-types";

Expand Down Expand Up @@ -486,34 +487,33 @@ class Profile {
} else {
await fetch(ENDPOINTS.forgot, {
method: "POST",
body: {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: email,
forgot: true,
},
json: true,
}),
})
.then((res) => {
if (res.statusCode === 200) {
.then(async (res) => {
let resJSON = await res.json();
if (resJSON.statusCode === 200) {
return resp;
} else {
if (res.errorMessage) {
console.error(res.errorMessage);
}
if (res.body) {
return res.body;
if (resJSON.body) {
resp.error = resJSON.body;
} else {
resp.error = "Unexpected Error";
return resp;
}
}
})
.catch((error) => {
resp.error =
error +
"An error occured when attempting to general url";
return resp;
});
}
return resp;
}
}
async Reset(email, password, conpassword, magic) {
Expand Down

0 comments on commit 477ad89

Please sign in to comment.