feat: back password reset email (#277)
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import API from '../API';
|
||||
import { useNavigation } from '../Navigation';
|
||||
import ForgotPasswordForm from '../components/forms/forgotPasswordForm';
|
||||
|
||||
const ForgotPasswordView = () => {
|
||||
const navigation = useNavigation();
|
||||
|
||||
async function handleSubmit(email: string) {
|
||||
try {
|
||||
await API.fetch({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
route: `/auth/forgot-password?email=${email}`,
|
||||
method: 'PUT',
|
||||
});
|
||||
navigation.navigate('Home');
|
||||
return 'email sent';
|
||||
} catch {
|
||||
return 'Error with email, please contact support';
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<ForgotPasswordForm onSubmit={handleSubmit} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ForgotPasswordView;
|
||||
@@ -0,0 +1,34 @@
|
||||
import API from '../API';
|
||||
import { useNavigation } from '../Navigation';
|
||||
import { useRoute } from '@react-navigation/native';
|
||||
import PasswordResetForm from '../components/forms/passwordResetForm';
|
||||
|
||||
const PasswordResetView = () => {
|
||||
const navigation = useNavigation();
|
||||
const route = useRoute();
|
||||
|
||||
const handlePasswordReset = async (password: string) => {
|
||||
try {
|
||||
await API.fetch({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
route: `/auth/password-reset?token=${(route.params as any).token}`,
|
||||
method: 'PUT',
|
||||
body: {
|
||||
password,
|
||||
},
|
||||
});
|
||||
navigation.navigate('Home');
|
||||
return 'password succesfully reset';
|
||||
} catch {
|
||||
return 'password reset failed';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PasswordResetForm onSubmit={(password) => handlePasswordReset(password)} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PasswordResetView;
|
||||
@@ -100,7 +100,7 @@ const SigninView = () => {
|
||||
}}
|
||||
isRequired
|
||||
/>,
|
||||
<LinkBase key={'signin-link'} onPress={() => console.log('Link clicked!')}>
|
||||
<LinkBase key={'signin-link'} onPress={() => navigation.navigate('ForgotPassword')}>
|
||||
{translate('forgottenPassword')}
|
||||
</LinkBase>,
|
||||
]}
|
||||
|
||||
@@ -178,6 +178,23 @@ const StartPageView = () => {
|
||||
</Link>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
style={{
|
||||
width: '90%',
|
||||
marginTop: 20,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Link href="/forgot_password">I forgot my password</Link>
|
||||
</Box>
|
||||
</Box>
|
||||
</Column>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user