-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: the generate forgot password link to be a post request.
Also after sending login and signup requests, make the payload to be null, so it's not saved in the heap
- Loading branch information
1 parent
207b8b6
commit d5e3cc7
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ export const ForgotPassword = ({ navigation }) => { | |
const [data, setData] = useState({ email: "" }); | ||
const [errors, setErrors] = useState({}); | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const schema = Joi.object({ | ||
email: Joi.string() | ||
|
@@ -32,6 +33,7 @@ export const ForgotPassword = ({ navigation }) => { | |
}); | ||
|
||
const handleResetPassword = async () => { | ||
setLoading(true); | ||
if ((await validate(data, schema, setErrors)) == null) { | ||
try { | ||
await userSvc.generateForgotPasswordLink( | ||
|
@@ -44,6 +46,7 @@ export const ForgotPassword = ({ navigation }) => { | |
setErrors({ submit: errorMessage }); | ||
} | ||
} | ||
setLoading(false); | ||
}; | ||
|
||
const canContinue = data.email === ""; | ||
|
@@ -58,6 +61,7 @@ export const ForgotPassword = ({ navigation }) => { | |
<Input | ||
label={t("input_email_label")} | ||
value={data.email} | ||
autoCapitalize="none" | ||
placeholder={"[email protected]"} | ||
onChange={(value) => setData({ email: value })} | ||
errorMessage={errors.email} | ||
|
@@ -69,6 +73,7 @@ export const ForgotPassword = ({ navigation }) => { | |
size="lg" | ||
onPress={handleResetPassword} | ||
disabled={canContinue} | ||
loading={loading} | ||
style={styles.button} | ||
/> | ||
</View> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters