Skip to content

Commit 792cb94

Browse files
author
Jovert Lota Palonpon
committed
wip
1 parent 2d8febe commit 792cb94

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
},
1818
"plugins": ["react"],
1919
"rules": {
20-
"indent": ["warn", 4],
2120
"linebreak-style": ["warn", "unix"],
2221
"quotes": ["warn", "single"],
2322
"semi": ["warn", "always"],

resources/js/views/auth/SignIn.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import { Link as RouterLink } from 'react-router-dom';
3-
import { Formik, Form, withFormik } from 'formik';
3+
import { Formik, Form } from 'formik';
44
import * as Yup from 'yup';
55

66
import {
@@ -64,10 +64,11 @@ class SignIn extends Component {
6464
* This should send an API request to identify the user.
6565
*
6666
* @param {string} username
67+
* @param {object} form
6768
*
6869
* @return {undefined}
6970
*/
70-
identify = async (username = null) => {
71+
identify = async (username = null, form = {}) => {
7172
this.setState({ loading: true });
7273

7374
try {
@@ -96,9 +97,10 @@ class SignIn extends Component {
9697
}
9798

9899
const { errors } = error.response.data;
99-
const { setErrors } = this.props;
100100

101-
setErrors(errors);
101+
if (errors) {
102+
form.setErrors(errors);
103+
}
102104

103105
this.setState({ loading: false });
104106
}
@@ -109,10 +111,11 @@ class SignIn extends Component {
109111
* Reload if authenticated.
110112
*
111113
* @param {object} values
114+
* @param {object} form
112115
*
113116
* @return {undefined}
114117
*/
115-
signin = async values => {
118+
signin = async (values, form = {}) => {
116119
this.setState({ loading: true });
117120

118121
try {
@@ -138,9 +141,10 @@ class SignIn extends Component {
138141
}
139142

140143
const { errors } = error.response.data;
141-
const { setErrors } = this.props;
142144

143-
setErrors(errors);
145+
if (errors) {
146+
form.setErrors(errors);
147+
}
144148

145149
this.setState({ loading: false });
146150
}
@@ -149,21 +153,24 @@ class SignIn extends Component {
149153
/**
150154
* Event listener that is triggered when the sign in form is submitted.
151155
*
156+
* @param {object} event
157+
* @param {object} form
158+
*
152159
* @return {undefined}
153160
*/
154-
handleSigninSubmit = async (values, { setSubmitting }) => {
155-
setSubmitting(false);
161+
handleSigninSubmit = async (values, form) => {
162+
form.setSubmitting(false);
156163

157164
try {
158165
const { identified } = this.state;
159166

160167
if (!identified) {
161-
await this.identify(values.username);
168+
await this.identify(values.username, form);
162169

163170
return;
164171
}
165172

166-
await this.signin(values);
173+
await this.signin(values, form);
167174
} catch (error) {
168175
this.setState({
169176
loading: false,
@@ -242,7 +249,7 @@ class SignIn extends Component {
242249
})}
243250
>
244251
{({ values, handleChange, errors, isSubmitting }) => (
245-
<Form>
252+
<Form autoComplete="off">
246253
<Grid container direction="column">
247254
{!identified ? (
248255
<>
@@ -395,6 +402,4 @@ const styles = theme => ({
395402
},
396403
});
397404

398-
const Styled = withStyles(styles)(SignIn);
399-
400-
export default withFormik({})(Styled);
405+
export default withStyles(styles)(SignIn);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ class PasswordRequest extends Component {
2626
* Event listener that is triggered when the password request form is submitted.
2727
*
2828
* @param {object} event
29+
* @param {object} form
2930
*
3031
* @return {undefined}
3132
*/
32-
handleRequestPasswordSubmit = async (values, { setSubmitting }) => {
33+
handleRequestPasswordSubmit = async (
34+
values,
35+
{ setSubmitting, setErrors },
36+
) => {
3337
setSubmitting(false);
3438

3539
try {
@@ -69,7 +73,6 @@ class PasswordRequest extends Component {
6973
}
7074

7175
const { errors } = error.response.data;
72-
const { setErrors } = this.props;
7376

7477
setErrors(errors);
7578

@@ -124,7 +127,7 @@ class PasswordRequest extends Component {
124127
submitCount,
125128
isSubmitting,
126129
}) => (
127-
<Form>
130+
<Form autoComplete="off">
128131
<Grid container direction="column">
129132
<Grid item className={classes.formGroup}>
130133
<TextField

resources/js/views/auth/passwords/Reset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class PasswordReset extends Component {
5050
* Handle Password Reset submission.
5151
*
5252
* @param {object} event
53+
* @param {object} form
5354
*
5455
* @return {undefined}
5556
*/
@@ -177,7 +178,7 @@ class PasswordReset extends Component {
177178
submitCount,
178179
isSubmitting,
179180
}) => (
180-
<Form>
181+
<Form autoComplete="off">
181182
<Grid container direction="column">
182183
<Grid item className={classes.formGroup}>
183184
<TextField

0 commit comments

Comments
 (0)