File tree Expand file tree Collapse file tree 5 files changed +1817
-1667
lines changed
Expand file tree Collapse file tree 5 files changed +1817
-1667
lines changed Original file line number Diff line number Diff line change 5353 "babel-polyfill" : " ^6.26.0" ,
5454 "clsx" : " ^1.0.4" ,
5555 "lodash" : " ^4.17.11" ,
56- "material" : " ^0.4.1" ,
5756 "material-table" : " ^1.39.2" ,
5857 "mobx" : " ^5.9.4" ,
5958 "mobx-react" : " ^5.4.3" ,
6463 "query-string" : " ^6.9.0" ,
6564 "react" : " ^16.3.0" ,
6665 "react-dom" : " ^16.3.0" ,
67- "react-router-dom" : " ^5.1.2" ,
68- "src" : " ^1.1.2"
66+ "react-router-dom" : " ^5.1.2"
6967 },
7068 "devDependencies" : {
7169 "@babel/core" : " ^7.0.0-0" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import FormControl from "@material-ui/core/FormControl"
1010import InputLabel from "@material-ui/core/InputLabel"
1111import Input from "@material-ui/core/Input"
1212import Button from "@material-ui/core/Button"
13+ import Typography from "@material-ui/core/Typography"
1314
1415const LoginForm = observer ( ( { location } ) => {
1516 const rootStore = useContext ( rootStoreContext )
@@ -40,6 +41,7 @@ const LoginForm = observer(({ location }) => {
4041 type = "username"
4142 value = { username }
4243 onChange = { changeUsername }
44+ error = { rootStore . authStore . error }
4345 required
4446 />
4547 </ FormControl >
@@ -53,13 +55,24 @@ const LoginForm = observer(({ location }) => {
5355 value = { password }
5456 type = "password"
5557 onChange = { changePassword }
58+ error = { rootStore . authStore . error }
5659 required
5760 />
5861 </ FormControl >
5962 </ FormGroup >
6063 < Button type = "submit" variant = "contained" style = { { marginTop : "10px" } } >
6164 Sign In
6265 </ Button >
66+ { rootStore . authStore . error && (
67+ < Typography
68+ className = "login-form__error"
69+ component = "p"
70+ variant = "body2"
71+ gutterBottom
72+ >
73+ Incorrect Username or password
74+ </ Typography >
75+ ) }
6376 </ form >
6477 </ div >
6578 )
Original file line number Diff line number Diff line change 77 max-width : 320px ;
88 }
99 }
10+
11+ .login-form__error {
12+ color : #ff000f ;
13+ padding-top : 10px ;
14+ }
1015}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export class AuthStore {
1010 @observable isAuthenticated = null
1111 @observable username = null
1212 @observable email = null
13+ @observable error = null
1314
1415 @action
1516 setIsAuthenticated ( auth ) {
@@ -24,6 +25,10 @@ export class AuthStore {
2425 this . username = email
2526 }
2627 @action
28+ setError ( error ) {
29+ this . error = error
30+ }
31+ @action
2732 logout ( ) {
2833 localStorage . removeItem ( "JWT_ACCESS" )
2934 localStorage . removeItem ( "JWT_REFRESH" )
@@ -39,9 +44,12 @@ export class AuthStore {
3944 this . setIsAuthenticated ( true )
4045 this . setUsername ( data . username )
4146 this . setEmail ( data . email )
47+ this . setError ( data . null )
48+ } else {
49+ throw new Error ( )
4250 }
4351 } catch ( error ) {
44- throw "AuthStore: login() Failed => " + error
52+ this . setError ( true )
4553 }
4654 } )
4755}
You can’t perform that action at this time.
0 commit comments