Add notification on failure to login.

This commit is contained in:
Ceda EI 2019-03-29 16:17:15 +05:30
parent 27033c5a99
commit cf1d58d6fd
4 changed files with 25 additions and 4 deletions

View File

@ -9,7 +9,8 @@
"prop-types": "^15.7.2",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-scripts": "2.1.8"
"react-scripts": "2.1.8",
"sweetalert": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",

View File

@ -6,6 +6,7 @@ dependencies:
react: 16.8.6
react-dom: 16.8.6
react-scripts: 2.1.8
sweetalert: 2.1.2
packages:
/@babel/code-frame/7.0.0:
dependencies:
@ -4030,6 +4031,10 @@ packages:
node: '>= 0.4'
resolution:
integrity: sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==
/es6-object-assign/1.1.0:
dev: false
resolution:
integrity: sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=
/escape-html/1.0.3:
dev: false
resolution:
@ -8730,6 +8735,10 @@ packages:
dev: false
resolution:
integrity: sha1-mEcocL8igTL8vdhoEputEsPAKeM=
/promise-polyfill/6.1.0:
dev: false
resolution:
integrity: sha1-36lpQ+qcEh/KTem1hoyznTRy4Fc=
/promise/8.0.2:
dependencies:
asap: 2.0.6
@ -10208,6 +10217,13 @@ packages:
hasBin: true
resolution:
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:
dev: false
resolution:
@ -11273,3 +11289,4 @@ specifiers:
react: ^16.8.4
react-dom: ^16.8.4
react-scripts: 2.1.8
sweetalert: ^2.1.2

View File

@ -1,7 +1,7 @@
import React, { useState } from "react";
import PropTypes from "prop-types";
export default (player) => {
export default (player, swal) => {
function Login(props) {
const [input, setInput] = useState(localStorage.getItem("token") ? localStorage.getItem("token"): "" );
return (
@ -13,10 +13,12 @@ export default (player) => {
onClick={
() => player.auth(input)
.then(x => {
props.setLoggedIn(x);
if (x === true) {
localStorage.setItem("token", input);
} else {
swal("Invalid Token");
}
props.setLoggedIn(x);
})
}>Submit</button>
</div>

View File

@ -7,10 +7,11 @@ import axios from "axios";
import login from "./components/login";
import mainapp from "./components/mainapp";
import models from "./models";
import swal from "sweetalert";
const { player } = models(config, axios);
const Login = login(player);
const Login = login(player, swal);
const MainApp = mainapp(player);
function App(){