Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 84a7c51d
authored
2024-06-17 12:40:04 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.
1 parent
b754dfc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletions
components/login/Login.js
components/login/Login.js
View file @
84a7c51
...
...
@@ -10,7 +10,8 @@ import { useRouter } from "next/router";
import
{
signIn
}
from
"next-auth/react"
;
import
{
toast
}
from
"react-toastify"
;
import
{
Loader
}
from
"react-bootstrap-typeahead"
;
import
axios
from
"axios"
;
import
qs
from
"qs"
;
const
Login
=
props
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
loginValidationSchema
=
Yup
.
object
().
shape
({
...
...
@@ -34,6 +35,36 @@ const Login = props => {
validationSchema
=
{
loginValidationSchema
}
// enableReinitialize={true}
onSubmit
=
{
async
values
=>
{
const
userConfig
=
{
headers
:
{
"Content-Type"
:
"application/json"
}
};
const
query
=
{
filters
:
{
email
:
{
$eq
:
values
.
email
}
},
populate
:
[
"role"
],
// fields: ["email", "role"]
};
const
queryString
=
qs
.
stringify
(
query
,
{
encodeValuesOnly
:
true
});
const
existingUser
=
await
axios
.
get
(
`
${
process
.
env
.
NEXT_PUBLIC_BACKEND_API_URL
}
/api/users?
${
queryString
}
`
,
userConfig
);
// console.log("existingUser", existingUser);
if
(
props
.
type
==
"vendor"
)
{
if
(
existingUser
.
data
[
0
].
role
.
name
!=
"vendor"
)
{
toast
.
error
(
"This is vendor login, please use the login functionality in menu."
);
return
;
}
}
if
(
props
.
type
==
"user"
)
{
if
(
existingUser
.
data
[
0
].
role
.
name
!=
"endUser"
)
{
toast
.
error
(
"This is user login, please use the vendor login functionality in bottom menu."
);
return
;
}
}
// return;
setLoading
(
true
);
console
.
log
(
"login values"
,
values
);
const
signInResponse
=
await
signIn
(
"credentials"
,
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment