Login verification
This commit is contained in:
parent
f7b4ef09a7
commit
9c759f44d1
34
src/App.js
34
src/App.js
@ -11,7 +11,8 @@ import {XSquareFill, PlusCircle, LifePreserver, Server, CloudUploadFill} from 'r
|
|||||||
import {
|
import {
|
||||||
HashRouter,
|
HashRouter,
|
||||||
Switch,
|
Switch,
|
||||||
Route
|
Route,
|
||||||
|
useHistory
|
||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
|
|
||||||
import { HashLink as Link } from 'react-router-hash-link';
|
import { HashLink as Link } from 'react-router-hash-link';
|
||||||
@ -576,6 +577,21 @@ function FormField(p) {
|
|||||||
p.type==="toggle"?<><Toggle id={p.field} checked={p.checked} onChange={p.onChange} disabled={p.loading}/> <label className="formDescription" for={p.field}>{p.checked?<b>YES</b>:<b>NO</b>}</label></>:<input type={p.type??"text"} disabled={p.loading} id={p.field} maxlength={p.maxlength} value={p.value} checked={p.checked} onChange={p.onChange} placeholder={p.placeholder}/>} <label className="formDescription" for={p.field}>{p.tooltip}</label></>
|
p.type==="toggle"?<><Toggle id={p.field} checked={p.checked} onChange={p.onChange} disabled={p.loading}/> <label className="formDescription" for={p.field}>{p.checked?<b>YES</b>:<b>NO</b>}</label></>:<input type={p.type??"text"} disabled={p.loading} id={p.field} maxlength={p.maxlength} value={p.value} checked={p.checked} onChange={p.onChange} placeholder={p.placeholder}/>} <label className="formDescription" for={p.field}>{p.tooltip}</label></>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function VerifyLogin(p) {
|
||||||
|
axios.post(GetBackendURL(p)+"/validUser",{
|
||||||
|
username:p.LOGGEDINUSER,
|
||||||
|
password:p.LOGGEDINHASH
|
||||||
|
})
|
||||||
|
.then((data)=>{
|
||||||
|
if (data.data.verified) {
|
||||||
|
p.history.push("/")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err)=>{
|
||||||
|
console.log(err.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function LoginForm(p) {
|
function LoginForm(p) {
|
||||||
const [username,setUsername] = useState("")
|
const [username,setUsername] = useState("")
|
||||||
const [password,setPassword] = useState("")
|
const [password,setPassword] = useState("")
|
||||||
@ -583,6 +599,12 @@ function LoginForm(p) {
|
|||||||
const [error,setError] = useState("")
|
const [error,setError] = useState("")
|
||||||
const [loading,setLoading] = useState(false)
|
const [loading,setLoading] = useState(false)
|
||||||
|
|
||||||
|
const history = useHistory()
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
VerifyLogin({...p,history:history})
|
||||||
|
},[])
|
||||||
|
|
||||||
function SubmitLogin() {
|
function SubmitLogin() {
|
||||||
setError("")
|
setError("")
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
@ -630,6 +652,12 @@ function RegisterForm(p) {
|
|||||||
const [error,setError] = useState("")
|
const [error,setError] = useState("")
|
||||||
const [loading,setLoading] = useState(false)
|
const [loading,setLoading] = useState(false)
|
||||||
|
|
||||||
|
const history = useHistory()
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
VerifyLogin({...p,history:history})
|
||||||
|
},[])
|
||||||
|
|
||||||
function SubmitRegister() {
|
function SubmitRegister() {
|
||||||
setError("")
|
setError("")
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
@ -719,8 +747,8 @@ function App() {
|
|||||||
const [DATA,setDATA] = useState({GetData:()=>{}})
|
const [DATA,setDATA] = useState({GetData:()=>{}})
|
||||||
const [DATAID,setDATAID] = useState({GetData:()=>{}})
|
const [DATAID,setDATAID] = useState({GetData:()=>{}})
|
||||||
|
|
||||||
const [LOGGEDINUSER,setLOGGEDINUSER] = useState(undefined)
|
const [LOGGEDINUSER,setLOGGEDINUSER] = useState("sigonasr2")
|
||||||
const [LOGGEDINHASH,setLOGGEDINHASH] = useState(undefined)
|
const [LOGGEDINHASH,setLOGGEDINHASH] = useState("7355ddfc5b81291cdd2c3025976c108c")
|
||||||
|
|
||||||
|
|
||||||
function GetData(table,row,col,id){
|
function GetData(table,row,col,id){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user