Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-049
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-049
2021-049
Commits
08898267
Commit
08898267
authored
Aug 06, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login Created
parent
f8fc471f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
20 deletions
+42
-20
BackEnd/WebBackEnd/routes/userAccount.route.js
BackEnd/WebBackEnd/routes/userAccount.route.js
+11
-0
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
+31
-20
No files found.
BackEnd/WebBackEnd/routes/userAccount.route.js
View file @
08898267
...
...
@@ -20,7 +20,18 @@ router.route('/update/:id').post((req,res) =>{
})
});
router
.
route
(
'
/getCredentials
'
).
post
((
req
,
res
)
=>
{
const
email
=
req
.
body
.
user_email
;
const
password
=
req
.
body
.
user_password
;
userAccount
.
find
({
user_email
:
email
,
user_password
:
password
},
function
(
err
,
User
)
{
}).
then
(
User
=>
res
.
json
(
User
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
});
module
.
exports
=
router
;
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
View file @
08898267
import
React
,
{
Component
}
from
"
react
"
;
import
ItemNav
from
"
./Navbar
"
;
import
axios
from
"
axios
"
;
export
default
class
Login
extends
Component
{
...
...
@@ -22,29 +22,40 @@ export default class Login extends Component{
e
.
preventDefault
();
const
LogUser
=
{
email
:
this
.
state
.
email
,
password
:
this
.
state
.
password
user_
email
:
this
.
state
.
email
,
user_
password
:
this
.
state
.
password
}
const
email
=
this
.
state
.
email
;
// axios.post('http://localhost:5000/newUser/getCredentials', LogUser)
// .then(response => {
// console.log(response.data);
// if (response.data.length > 0) {
// console.log(response.data);
// console.log(response.data.password);
//
// localStorage.setItem("Name",response.data[0].name);
// localStorage.setItem("userID",response.data[0].id);
// window.location = '/Places';
// }
// else {
// alert("Email or Password Invalid!!!")
// }
//
//
// });
axios
.
post
(
'
http://localhost:5000/userAccount/getCredentials
'
,
LogUser
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
);
if
(
response
.
data
.
length
>
0
)
{
console
.
log
(
response
.
data
);
console
.
log
(
response
.
data
.
password
);
// localStorage.setItem("Name",response.data[0].name);
// localStorage.setItem("userID",response.data[0].id);
if
(
response
.
data
[
0
].
user_type
===
'
Student
'
){
window
.
location
=
'
/Home
'
;
}
else
if
(
response
.
data
[
0
].
user_type
===
'
Tutor
'
){
window
.
location
=
'
/admin
'
;
}
else
if
(
response
.
data
[
0
].
user_type
===
'
Institute
'
){
window
.
location
=
'
/admin
'
;
}
//window.location = '/Places';
}
else
{
alert
(
"
Email or Password Invalid!!!
"
)
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment