diff --git a/src/components/Forgot.jsx b/src/components/Forgot.jsx index b1bb4562..9b5011a4 100644 --- a/src/components/Forgot.jsx +++ b/src/components/Forgot.jsx @@ -1,39 +1,40 @@ import React, { useState } from "react"; -// import { Container, Grid, createMuiTheme, ThemeProvider} from "@material-ui/core"; -import { Container, Grid } from "@material-ui/core"; +import { Container, Grid, createMuiTheme, ThemeProvider} from "@material-ui/core"; +//import { Container, Grid } from "@material-ui/core"; import Alert from "@material-ui/lab/Alert"; import { Link } from "react-router-dom"; import { Redirect } from "react-router-dom"; import AuthForm from "../library/AuthForm"; import ColorButton from "../library/ColorButton"; -// import WhiteTextField from "../library/WhiteTextField"; +import WhiteTextField from "../library/WhiteTextField"; import PropTypes from "prop-types"; -// import { theme } from "../Defaults"; +import { theme } from "../Defaults"; /** * Forgot my password application for "/forgot" */ -// const color_theme = createMuiTheme({ - -// overrides: { -// palette: { -// primary: { -// main: theme.primary[1].trim(), -// }, -// secondary: { -// main: theme.secondary[1].trim(), -// }, -// }, -// MuiInputLabel: { -// root: { -// color: "white", -// "&$focused": { -// color: "white" -// } -// } -// } -// } -// }); +const color_theme = createMuiTheme({ + + overrides: { + palette: { + primary: { + main: theme.primary[1].trim(), + }, + secondary: { + main: theme.secondary[1].trim(), + }, + }, + MuiInputLabel: { + root: { + color: "white", + "&$focused": { + color: "white" + } + } + } + } +}); + const ForgotPage = (props) => { @@ -42,23 +43,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); + if (msg.error) { + setLoading(false); + setErrors(msg.error); + } else { + setLoading(false); + setDone(true); + setErrors(""); + } + } }; @@ -102,7 +102,7 @@ const ForgotPage = (props) => { spacing={2}> - {/* + { { autoComplete="email" size="small" /> - */} + } + {/*
Please reach out to rnd@hackru.org to reset password -
+ */}
- {/* + { { Submit - */} + } + {/* @@ -143,7 +145,8 @@ const ForgotPage = (props) => { color="primary"> Email Us - + + */} diff --git a/src/components/Profile.js b/src/components/Profile.js index 04f2d8a2..94ac285d 100644 --- a/src/components/Profile.js +++ b/src/components/Profile.js @@ -1,3 +1,4 @@ +//import { ControlCameraSharp } from "@material-ui/icons"; import { defaults } from "../Defaults"; import PropTypes from "prop-types"; @@ -486,24 +487,23 @@ 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; } } }) @@ -511,9 +511,9 @@ class Profile { resp.error = error + "An error occured when attempting to general url"; - return resp; }); } + return resp; } } async Reset(email, password, conpassword, magic) {