Skip to content

Commit c451610

Browse files
author
Jovert Lota Palonpon
committed
wip #39
1 parent 2c38626 commit c451610

File tree

7 files changed

+372
-96
lines changed

7 files changed

+372
-96
lines changed

app/Http/Controllers/Api/V1/Auth/ForgotPasswordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function sendResetLinkEmail(Request $request) : JsonResponse
3232
$request->input('routeSuffix'),
3333
':',
3434
true
35-
).$token;
35+
).$token.'?email='.$user->email;
3636

3737
$resetLink = route('backoffice.welcome').'#'.$routeSuffix;
3838

resources/js/views/auth/passwords/Request.js

+80-93
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { Formik, Form, withFormik } from 'formik';
44
import * as Yup from 'yup';
55
import { Grid, TextField, Button, Link, withStyles } from '@material-ui/core';
66

7-
import { Auth as AuthLayout } from '../../layouts';
87
import * as NavigationUtils from '../../../utils/Navigation';
98
import * as UrlUtils from '../../../utils/URL';
9+
import { Auth as AuthLayout } from '../../layouts';
1010

1111
class PasswordRequest extends Component {
1212
state = {
@@ -37,22 +37,20 @@ class PasswordRequest extends Component {
3737
routeSuffix,
3838
});
3939

40-
if (response.status === 200) {
41-
this.setState({
42-
loading: false,
43-
message: {
44-
type: 'success',
45-
title: 'Link Sent',
46-
body: (
47-
<h4>
48-
Check your email to reset your account.
49-
<br /> Thank you.
50-
</h4>
51-
),
52-
action: () => history.push(`/signin?username=${email}`),
53-
},
54-
});
55-
}
40+
this.setState({
41+
loading: false,
42+
message: {
43+
type: 'success',
44+
title: 'Link Sent',
45+
body: (
46+
<h4>
47+
Check your email to reset your account.
48+
<br /> Thank you.
49+
</h4>
50+
),
51+
action: () => history.push(`/signin?username=${email}`),
52+
},
53+
});
5654
} catch (error) {
5755
if (!error.response) {
5856
this.setState({
@@ -95,8 +93,7 @@ class PasswordRequest extends Component {
9593
}
9694

9795
render() {
98-
const { classes, location, setErrors, errors: formErrors } = this.props;
99-
96+
const { classes, location } = this.props;
10097
const { loading, message, email } = this.state;
10198

10299
return (
@@ -114,88 +111,78 @@ class PasswordRequest extends Component {
114111
: email,
115112
}}
116113
onSubmit={this.handleRequestPasswordSubmit}
117-
validate={values => {
118-
setErrors({});
119-
}}
120114
validationSchema={Yup.object().shape({
121115
email: Yup.string().required(
122-
`The email field is required`,
116+
Lang.get('validation.required', {
117+
attribute: 'email',
118+
}),
123119
),
124120
})}
125121
>
126-
{({ values, handleChange, errors, isSubmitting }) => {
127-
if (formErrors && Object.keys(formErrors).length > 0) {
128-
errors = formErrors;
129-
}
130-
131-
return (
132-
<Form>
133-
<Grid container direction="column">
134-
<Grid item className={classes.formGroup}>
135-
<TextField
136-
id="email"
137-
type="email"
138-
label="Email"
139-
value={values.email}
140-
onChange={handleChange}
141-
variant="outlined"
142-
fullWidth
143-
error={errors.hasOwnProperty(
144-
'email',
145-
)}
146-
helperText={
147-
errors.hasOwnProperty(
148-
'email',
149-
) && errors.email
150-
}
151-
/>
152-
</Grid>
153-
154-
<Grid item className={classes.formGroup}>
155-
<Link
156-
component={props => (
157-
<RouterLink
158-
{...props}
159-
to={{
160-
search: UrlUtils._queryString(
161-
{
162-
username: email,
163-
},
164-
),
165-
pathname: NavigationUtils._route(
166-
'auth.signin',
167-
),
168-
}}
169-
/>
170-
)}
171-
>
172-
{Lang.get('navigation.signin')}
173-
</Link>
174-
</Grid>
122+
{({ values, handleChange, errors, isSubmitting }) => (
123+
<Form>
124+
<Grid container direction="column">
125+
<Grid item className={classes.formGroup}>
126+
<TextField
127+
id="email"
128+
type="email"
129+
label="Email"
130+
value={values.email}
131+
onChange={handleChange}
132+
variant="outlined"
133+
fullWidth
134+
error={errors.hasOwnProperty('email')}
135+
helperText={
136+
errors.hasOwnProperty('email') &&
137+
errors.email
138+
}
139+
/>
175140
</Grid>
176141

177-
<Grid container justify="space-between">
178-
<Grid item />
179-
180-
<Grid item className={classes.formGroup}>
181-
<Button
182-
type="submit"
183-
variant="contained"
184-
color="primary"
185-
disabled={
186-
(errors &&
187-
Object.keys(errors).length >
188-
0) ||
189-
isSubmitting
190-
}
191-
>
192-
{Lang.get('navigation.send_link')}
193-
</Button>
194-
</Grid>
142+
<Grid item className={classes.formGroup}>
143+
<Link
144+
component={props => (
145+
<RouterLink
146+
{...props}
147+
to={{
148+
search: UrlUtils._queryString(
149+
{
150+
username: email,
151+
},
152+
),
153+
pathname: NavigationUtils._route(
154+
'auth.signin',
155+
),
156+
}}
157+
/>
158+
)}
159+
>
160+
{Lang.get('navigation.signin')}
161+
</Link>
195162
</Grid>
196-
</Form>
197-
);
198-
}}
163+
</Grid>
164+
165+
<Grid container justify="space-between">
166+
<Grid item />
167+
168+
<Grid item className={classes.formGroup}>
169+
<Button
170+
type="submit"
171+
variant="contained"
172+
color="primary"
173+
disabled={
174+
(errors &&
175+
Object.keys(errors).length >
176+
0) ||
177+
isSubmitting
178+
}
179+
>
180+
{Lang.get('navigation.send_link')}
181+
</Button>
182+
</Grid>
183+
</Grid>
184+
</Form>
185+
)}
199186
</Formik>
200187
</AuthLayout>
201188
);

0 commit comments

Comments
 (0)