30112023
This commit is contained in:
@@ -63,11 +63,13 @@ const Login = () => {
|
||||
// }, [toast])
|
||||
|
||||
useEffect(() => {
|
||||
if (localStorage.getItem("firstname") || localStorage.getItem("appuserid")) {
|
||||
if (localStorage.getItem("authname")
|
||||
// || localStorage.getItem("appuserid")
|
||||
) {
|
||||
navigate('/dashboard')
|
||||
}
|
||||
|
||||
console.log(alertmessage)
|
||||
// console.log(alertmessage)
|
||||
}, [])
|
||||
|
||||
const usernamecheck = async (e) => {
|
||||
@@ -78,17 +80,20 @@ const Login = () => {
|
||||
// await axios.post(`${process.env.REACT_APP_URL}/auth/login`, {
|
||||
// "authname": e.target.value
|
||||
// })
|
||||
await axios.post(`${process.env.REACT_APP_URL2}/users/login`, {
|
||||
await axios.post(`${process.env.REACT_APP_URL}/users/login`, {
|
||||
"authname": e.target.value,
|
||||
"configid":3,
|
||||
// "password":'admi'
|
||||
"configid":1,
|
||||
"password":'admin'
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.userinfo.authname === e.target.value) {
|
||||
console.log(res.data)
|
||||
if (res.data.details.authname === e.target.value) {
|
||||
|
||||
setUsername(e.target.value);
|
||||
setCheckusername(false);
|
||||
}else{
|
||||
setCheckusername(true);
|
||||
|
||||
}
|
||||
// if (res.data.authname === e.target.value) {
|
||||
|
||||
@@ -96,10 +101,10 @@ const Login = () => {
|
||||
// setCheckusername(false);
|
||||
// }
|
||||
}).catch((err) => {
|
||||
if (err.response.data.message === 'No user found') {
|
||||
// if (err.response.data.message === 'No user found') {
|
||||
|
||||
setCheckusername(true);
|
||||
}
|
||||
// }
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
@@ -115,13 +120,13 @@ const Login = () => {
|
||||
if (password && username) {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await axios.post(`${process.env.REACT_APP_URL2}/users/login`, {
|
||||
await axios.post(`${process.env.REACT_APP_URL}/users/login`, {
|
||||
"authname": username,
|
||||
"configid":3,
|
||||
"configid":1,
|
||||
"password": password
|
||||
}).then((res) => {
|
||||
console.log(res.data)
|
||||
if (res.data.userinfo.authname === username) {
|
||||
if (res.data.details.authname === username) {
|
||||
// setAlertmessage('login Successfull');
|
||||
setLoading(false)
|
||||
// dispatch(
|
||||
@@ -141,12 +146,14 @@ const Login = () => {
|
||||
})
|
||||
setUsername('');
|
||||
setPassword('');
|
||||
localStorage.setItem("firstname", res.data.userinfo.firstname);
|
||||
localStorage.setItem("appuserid", res.data.userinfo.userid);
|
||||
localStorage.setItem("roleid", res.data.userinfo.roleid);
|
||||
localStorage.setItem("firstname", res.data.details.firstname);
|
||||
localStorage.setItem("authname", res.data.details.authname);
|
||||
|
||||
localStorage.setItem("appuserid", res.data.details.userid);
|
||||
localStorage.setItem("roleid", res.data.details.roleid);
|
||||
|
||||
|
||||
navigate('/dashboard', { state: { firstname: res.data.userinfo.firstname } });
|
||||
navigate('/dashboard');
|
||||
setSubmitting(false)
|
||||
}
|
||||
}).catch((err) => {
|
||||
@@ -226,7 +233,9 @@ const Login = () => {
|
||||
container
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
|
||||
// sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 112px)' } }}
|
||||
sx={{ minHeight: { xs: 'calc(100vh - 210px)', sm: 'calc(100vh - 134px)', md: 'calc(100vh - 132px)' } }}
|
||||
|
||||
>
|
||||
<Grid item>
|
||||
{/* <AuthCard>{children}</AuthCard> */}
|
||||
@@ -398,8 +407,8 @@ const Login = () => {
|
||||
disabled={submitting}
|
||||
|
||||
onClick={()=>{
|
||||
// loginsend()
|
||||
navigate('/dashboard')
|
||||
loginsend()
|
||||
// navigate('/dashboard')
|
||||
}}
|
||||
fullWidth size="large" type="submit" variant="contained" color="primary">
|
||||
Login
|
||||
|
||||
Reference in New Issue
Block a user