File tree 3 files changed +22
-8
lines changed
3 files changed +22
-8
lines changed Original file line number Diff line number Diff line change 10
10
font-family : 'Lato' , sans-serif;
11
11
}
12
12
13
+ .login-page__login-error {
14
+ color : red;
15
+ padding-bottom : 10px ;
16
+ }
17
+
13
18
.login-page__username ,
14
19
.login-page__password {
15
20
text-align : right;
Original file line number Diff line number Diff line change @@ -32,12 +32,13 @@ class LoginPage extends Component {
32
32
user_name . value = ''
33
33
password . value = ''
34
34
TokenService . saveAuthToken ( res . authToken )
35
+ this . handleLoginSuccess ( )
35
36
} )
36
37
. catch ( res => {
37
- this . setState ( { error : res . error } )
38
+ user_name . value = ''
39
+ password . value = ''
40
+ this . setState ( { error : true } )
38
41
} )
39
-
40
- this . handleLoginSuccess ( )
41
42
}
42
43
43
44
handleLoginSuccess = ( ) => {
@@ -50,10 +51,14 @@ class LoginPage extends Component {
50
51
}
51
52
52
53
render ( ) {
54
+ const loginFailed = this . state . error
55
+ ? < div className = 'login-page__login-error' > Incorrect username or password</ div >
56
+ : null
53
57
54
58
return (
55
59
< div className = 'login-page' >
56
60
< h2 > Login</ h2 >
61
+ { loginFailed }
57
62
< form
58
63
className = 'login-page__form'
59
64
onSubmit = { this . handleSubmitJwtAuth } >
Original file line number Diff line number Diff line change @@ -9,11 +9,15 @@ const AuthApiService = {
9
9
} ,
10
10
body : JSON . stringify ( credentials ) ,
11
11
} )
12
- . then ( res =>
13
- ( ! res . ok )
14
- ? res . json ( ) . then ( e => Promise . reject ( e ) )
15
- : res . json ( )
16
- )
12
+ . then ( res => {
13
+ if ( ! res . ok ) {
14
+ return res . json ( )
15
+ . then ( error => {
16
+ throw error
17
+ } )
18
+ }
19
+ return res . json ( )
20
+ } )
17
21
} ,
18
22
}
19
23
You can’t perform that action at this time.
0 commit comments