Add notification on failure to login.
This commit is contained in:
parent
27033c5a99
commit
cf1d58d6fd
|
@ -9,7 +9,8 @@
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
"react": "^16.8.4",
|
"react": "^16.8.4",
|
||||||
"react-dom": "^16.8.4",
|
"react-dom": "^16.8.4",
|
||||||
"react-scripts": "2.1.8"
|
"react-scripts": "2.1.8",
|
||||||
|
"sweetalert": "^2.1.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|
|
@ -6,6 +6,7 @@ dependencies:
|
||||||
react: 16.8.6
|
react: 16.8.6
|
||||||
react-dom: 16.8.6
|
react-dom: 16.8.6
|
||||||
react-scripts: 2.1.8
|
react-scripts: 2.1.8
|
||||||
|
sweetalert: 2.1.2
|
||||||
packages:
|
packages:
|
||||||
/@babel/code-frame/7.0.0:
|
/@babel/code-frame/7.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -4030,6 +4031,10 @@ packages:
|
||||||
node: '>= 0.4'
|
node: '>= 0.4'
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==
|
integrity: sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==
|
||||||
|
/es6-object-assign/1.1.0:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=
|
||||||
/escape-html/1.0.3:
|
/escape-html/1.0.3:
|
||||||
dev: false
|
dev: false
|
||||||
resolution:
|
resolution:
|
||||||
|
@ -8730,6 +8735,10 @@ packages:
|
||||||
dev: false
|
dev: false
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=
|
integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=
|
||||||
|
/promise-polyfill/6.1.0:
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=
|
||||||
/promise/8.0.2:
|
/promise/8.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
asap: 2.0.6
|
asap: 2.0.6
|
||||||
|
@ -10208,6 +10217,13 @@ packages:
|
||||||
hasBin: true
|
hasBin: true
|
||||||
resolution:
|
resolution:
|
||||||
integrity: sha512-xBfxJxfk4UeVN8asec9jNxHiv3UAMv/ujwBWGYvQhhMb2u3YTGKkiybPcLFDLq7GLLWE9wa73e0/m8L5nTzQbw==
|
integrity: sha512-xBfxJxfk4UeVN8asec9jNxHiv3UAMv/ujwBWGYvQhhMb2u3YTGKkiybPcLFDLq7GLLWE9wa73e0/m8L5nTzQbw==
|
||||||
|
/sweetalert/2.1.2:
|
||||||
|
dependencies:
|
||||||
|
es6-object-assign: 1.1.0
|
||||||
|
promise-polyfill: 6.1.0
|
||||||
|
dev: false
|
||||||
|
resolution:
|
||||||
|
integrity: sha512-iWx7X4anRBNDa/a+AdTmvAzQtkN1+s4j/JJRWlHpYE8Qimkohs8/XnFcWeYHH2lMA8LRCa5tj2d244If3S/hzA==
|
||||||
/symbol-tree/3.2.2:
|
/symbol-tree/3.2.2:
|
||||||
dev: false
|
dev: false
|
||||||
resolution:
|
resolution:
|
||||||
|
@ -11273,3 +11289,4 @@ specifiers:
|
||||||
react: ^16.8.4
|
react: ^16.8.4
|
||||||
react-dom: ^16.8.4
|
react-dom: ^16.8.4
|
||||||
react-scripts: 2.1.8
|
react-scripts: 2.1.8
|
||||||
|
sweetalert: ^2.1.2
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
export default (player) => {
|
export default (player, swal) => {
|
||||||
function Login(props) {
|
function Login(props) {
|
||||||
const [input, setInput] = useState(localStorage.getItem("token") ? localStorage.getItem("token"): "" );
|
const [input, setInput] = useState(localStorage.getItem("token") ? localStorage.getItem("token"): "" );
|
||||||
return (
|
return (
|
||||||
|
@ -13,10 +13,12 @@ export default (player) => {
|
||||||
onClick={
|
onClick={
|
||||||
() => player.auth(input)
|
() => player.auth(input)
|
||||||
.then(x => {
|
.then(x => {
|
||||||
props.setLoggedIn(x);
|
|
||||||
if (x === true) {
|
if (x === true) {
|
||||||
localStorage.setItem("token", input);
|
localStorage.setItem("token", input);
|
||||||
|
} else {
|
||||||
|
swal("Invalid Token");
|
||||||
}
|
}
|
||||||
|
props.setLoggedIn(x);
|
||||||
})
|
})
|
||||||
}>Submit</button>
|
}>Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,10 +7,11 @@ import axios from "axios";
|
||||||
import login from "./components/login";
|
import login from "./components/login";
|
||||||
import mainapp from "./components/mainapp";
|
import mainapp from "./components/mainapp";
|
||||||
import models from "./models";
|
import models from "./models";
|
||||||
|
import swal from "sweetalert";
|
||||||
|
|
||||||
const { player } = models(config, axios);
|
const { player } = models(config, axios);
|
||||||
|
|
||||||
const Login = login(player);
|
const Login = login(player, swal);
|
||||||
const MainApp = mainapp(player);
|
const MainApp = mainapp(player);
|
||||||
|
|
||||||
function App(){
|
function App(){
|
||||||
|
|
Loading…
Reference in New Issue