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
5fccce74
Commit
5fccce74
authored
Oct 13, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create User Login - functions
parent
bed0e292
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
202 additions
and
35 deletions
+202
-35
BackEnd/WebBackEnd/routes/userAccount.route.js
BackEnd/WebBackEnd/routes/userAccount.route.js
+63
-2
WebFrontEnd/smartcoach-frontend/src/App.js
WebFrontEnd/smartcoach-frontend/src/App.js
+1
-1
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorCard.js
.../smartcoach-frontend/src/Components/HomePage/TutorCard.js
+3
-2
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
+41
-17
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
+50
-8
WebFrontEnd/smartcoach-frontend/src/Components/Student/StudentDashboard.js
...coach-frontend/src/Components/Student/StudentDashboard.js
+44
-5
WebFrontEnd/smartcoach-frontend/src/Images/logout2.png
WebFrontEnd/smartcoach-frontend/src/Images/logout2.png
+0
-0
No files found.
BackEnd/WebBackEnd/routes/userAccount.route.js
View file @
5fccce74
const
router
=
require
(
'
express
'
).
Router
();
let
userAccount
=
require
(
'
../models/userAccount.user.model
'
);
let
StudentAccount
=
require
(
'
../models/student.user.model
'
);
let
TutorAccount
=
require
(
'
../models/tutor.user.model
'
);
let
InstituteAccount
=
require
(
'
../models/institute.user.model
'
);
router
.
route
(
'
/update/:id
'
).
post
((
req
,
res
)
=>
{
userAccount
.
findById
(
req
.
params
.
id
,
function
(
err
,
details
){
...
...
@@ -25,9 +28,67 @@ 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
))
userAccount
.
find
({
user_email
:
email
},
function
(
err
,
User
)
{
}).
then
(
User
=>
{
let
payload
=
{
user_id
:
User
[
0
].
user_id
,
user_email
:
User
[
0
].
user_email
,
user_name
:
''
,
user_type
:
User
[
0
].
user_type
}
console
.
log
(
User
);
if
(
User
.
length
>
0
){
console
.
log
(
password
);
console
.
log
(
User
[
0
].
user_password
);
if
(
User
[
0
].
user_password
===
password
){
console
.
log
(
"
inside password
"
)
if
(
User
[
0
].
confirmed
){
console
.
log
(
"
inside Confirmed
"
)
if
(
User
[
0
].
user_type
===
"
Student
"
){
console
.
log
(
"
inside student
"
)
StudentAccount
.
findById
(
User
[
0
].
user_id
).
then
(
result
=>
{
console
.
log
(
result
);
payload
.
user_name
=
result
.
student_name
res
.
json
(
payload
)
})
}
else
if
(
User
.
user_type
===
"
Tutor
"
){
TutorAccount
.
findById
(
User
[
0
].
user_id
).
then
(
result
=>
{
payload
.
user_name
=
result
.
tutor_name
res
.
json
(
payload
)
})
}
else
if
(
User
.
user_type
===
"
Institute
"
){
InstituteAccount
.
findById
(
User
[
0
].
user_id
).
then
(
result
=>
{
payload
.
user_name
=
result
.
institute_name
res
.
json
(
payload
)
})
}
}
else
{
res
.
json
(
"
Not Verified
"
)
}
}
else
{
res
.
json
(
"
Invalid Password
"
)
}
}
else
{
res
.
json
(
"
Not registered
"
)
}
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
...
...
WebFrontEnd/smartcoach-frontend/src/App.js
View file @
5fccce74
...
...
@@ -29,7 +29,7 @@ function App() {
<
Route
path
=
"
/beforeConfirm
"
exact
component
=
{
beforeConfirmation
}
/
>
<
Route
path
=
"
/AccountVerified/:id
"
exact
component
=
{
VerifiedAccount
}
/
>
<
Route
path
=
"
/Home/ViewProfile/:id
"
exact
component
=
{
TutorProfileView
}
/
>
{
/*<Route path="/studentDashboard" exact component={StudentDashboard}/>*/
}
<
Route
path
=
"
/studentDashboard
"
exact
component
=
{
StudentDashboard
}
/
>
{
/*<Route path="/" exact component={Dashboard}/>*/
}
...
...
WebFrontEnd/smartcoach-frontend/src/Components/HomePage/TutorCard.js
View file @
5fccce74
...
...
@@ -78,10 +78,11 @@ export default class TutorCard extends Component{
<
/div
>
<
div
className
=
"
row
"
>
<
div
className
=
"
col-1
"
>
<
img
src
=
{
Calender
}
style
=
{{
width
:
'
20px
'
,
height
:
'
20px
'
}}
/
>
<
br
/>
{
/*<img src={Calender} style={{width:'20px', height:'20px'}}/>*/
}
<
/div
>
<
div
className
=
"
col
"
>
<
h5
style
=
{{
float
:
"
left
"
}}
>
6
y
experience
<
/h5
>
{
/*<h5 style={{float:"left"}}>6y experience</h5>*/
}
<
/div
>
<
/div
>
<
div
className
=
"
row
"
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
View file @
5fccce74
import
React
,
{
Component
}
from
"
react
"
;
import
ItemNav
from
"
./Navbar
"
;
import
axios
from
"
axios
"
;
import
*
as
configs
from
"
../Config/config
"
;
import
swal
from
"
sweetalert
"
;
export
default
class
Login
extends
Component
{
...
...
@@ -28,31 +30,53 @@ export default class Login extends Component{
const
email
=
this
.
state
.
email
;
axios
.
post
(
'
http://localhost:5000
/userAccount/getCredentials
'
,
LogUser
)
axios
.
post
(
configs
.
BASE_URL
+
'
/userAccount/getCredentials
'
,
LogUser
)
.
then
(
response
=>
{
console
.
log
(
response
.
data
);
if
(
response
.
data
.
length
>
0
)
{
//console.log(response.data.length);
// if (response.data.length > 0) {
//console.log(response.data);
//console.log(response.data.password);
if
(
response
.
data
===
"
Invalid Password
"
){
swal
(
"
Sorry
"
,
"
Invalid Password
"
,
"
warning
"
);
}
else
if
(
response
.
data
===
"
Not registered
"
){
swal
(
"
Sorry
"
,
"
This email not registered!!!
"
,
"
warning
"
);
}
else
if
(
response
.
data
===
"
Not Verified
"
){
swal
(
"
Sorry
"
,
"
This email is not Verified
\n
Please verify your email first
"
,
"
warning
"
);
}
else
{
console
.
log
(
response
.
data
);
console
.
log
(
response
.
data
.
password
);
// localStorage.setItem("Name",response.data[0].name);
// localStorage.setItem("userID",response.data[0].id);
console
.
log
(
response
.
data
.
user_email
);
console
.
log
(
response
.
data
.
user_name
);
localStorage
.
setItem
(
"
email
"
,
response
.
data
.
user_email
);
localStorage
.
setItem
(
"
userID
"
,
response
.
data
.
user_id
);
localStorage
.
setItem
(
"
userName
"
,
response
.
data
.
user_name
);
localStorage
.
setItem
(
"
userType
"
,
response
.
data
.
user_type
);
if
(
response
.
data
[
0
]
.
user_type
===
'
Student
'
){
if
(
response
.
data
.
user_type
===
'
Student
'
){
window
.
location
=
'
/Home
'
;
}
else
if
(
response
.
data
[
0
]
.
user_type
===
'
Tutor
'
){
else
if
(
response
.
data
.
user_type
===
'
Tutor
'
){
window
.
location
=
'
/admin
'
;
}
else
if
(
response
.
data
[
0
]
.
user_type
===
'
Institute
'
){
else
if
(
response
.
data
.
user_type
===
'
Institute
'
){
window
.
location
=
'
/admin
'
;
}
}
//window.location = '/Places';
}
else
{
alert
(
"
Email or Password Invalid!!!
"
)
}
//}
// else {
// swal("Sorry", response.data, "warning");
//
// }
});
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Navbar.js
View file @
5fccce74
import
React
,
{
Component
}
from
'
react
'
;
import
Logo
from
"
../Images/logo.jpg
"
;
import
logout
from
"
../Images/logout2.png
"
;
export
default
class
NavBar
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
user_email
:
''
,
user_id
:
''
,
user_name
:
''
,
user_type
:
''
,
isLogged
:
false
}
}
componentDidMount
()
{
const
user_email
=
localStorage
.
getItem
(
"
email
"
);
const
user_id
=
localStorage
.
getItem
(
"
userID
"
);
const
user_name
=
localStorage
.
getItem
(
"
userName
"
);
const
user_type
=
localStorage
.
getItem
(
"
userType
"
);
if
(
user_id
!==
"
"
){
this
.
setState
({
isLogged
:
true
})
}
this
.
setState
({
user_email
:
user_email
,
user_id
:
user_id
,
user_name
:
user_name
,
user_type
:
user_type
})
console
.
log
(
user_email
);
console
.
log
(
user_name
);
}
render
()
{
return
(
...
...
@@ -16,26 +55,29 @@ export default class NavBar extends Component {
<
img
src
=
{
Logo
}
style
=
{{
width
:
'
200px
'
,
height
:
'
50px
'
}}
/
>
<
div
className
=
"
collapse navbar-collapse
"
id
=
"
navbarNavAltMarkup
"
>
<
div
className
=
"
navbar-nav
"
>
<
a
className
=
"
nav-item nav-link
"
style
=
{{
color
:
'
white
'
,
marginLeft
:
'
50px
'
}}
href
=
"
/Home
"
>
Home
<
span
<
a
className
=
"
nav-item nav-link
"
style
=
{{
color
:
'
white
'
,
marginLeft
:
'
50px
'
}}
href
=
"
/Home
"
>
<
h5
>
Home
<
/h5>
<spa
n
className
=
"
sr-only
"
>
(
current
)
<
/span></
a
>
<
/div
>
<
label
style
=
{{
position
:
'
absolute
'
,
top
:
'
15px
'
,
right
:
'
120px
'
,
color
:
'
#EAE4E4
'
}}
>
{
localStorage
.
getItem
(
"
Name
"
)
!=
null
?
localStorage
.
getItem
(
"
Name
"
)
:
<
label
onClick
=
{()
=>
{
color
:
'
#EAE4E4
'
,
marginRight
:
'
50px
'
}}
><
h5
>
{
this
.
state
.
user_name
!==
null
?
<
span
style
=
{{
cursor
:
'
pointer
'
}}
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/studentDashboard
"
);}}
>
{
this
.
state
.
user_name
}
<
/span> : <label onClick={
()
=>
{
window
.
location
.
replace
(
"
UserLogin
"
);
}}
>
Login
<
/label>} </
label
>
{
localStorage
.
getItem
(
"
Name
"
)
!=
null
&&
<
label
onClick
=
{()
=>
{
}}
>
Login
<
/label>} </
h5
><
/
label
>
{
this
.
state
.
user_name
!==
null
&&
<
img
src
=
{
logout
}
onClick
=
{()
=>
{
localStorage
.
clear
();
window
.
location
.
replace
(
"
/UserLogin
"
);
}}
style
=
{{
position
:
'
absolute
'
,
top
:
'
1
5px
'
,
right
:
'
30px
'
,
color
:
'
#EAE4E4
'
}}
>
Logout
<
/label
>
}
}}
style
=
{{
position
:
'
absolute
'
,
top
:
'
1
0px
'
,
right
:
'
30px
'
,
width
:
'
40px
'
,
height
:
'
40px
'
,
cursor
:
'
pointer
'
}}
/
>
}
{
/*{this.state.user_name !== null && <h5 onClick={() => {*/
}
{
/* localStorage.clear();*/
}
{
/* window.location.replace("/UserLogin");*/
}
{
/*}} style={{position: 'absolute', top: '15px', right: '30px', color: 'darkred'}}><b>Logout</b></h5>}*/
}
<
/div
>
<
/nav
>
...
...
WebFrontEnd/smartcoach-frontend/src/Components/Student/StudentDashboard.js
View file @
5fccce74
...
...
@@ -3,8 +3,46 @@ import React, {Component} from 'react';
import
{
Link
,
Route
}
from
"
react-router-dom
"
;
import
{
NavLink
}
from
"
react-router-dom
"
;
import
ALResults
from
"
./ALResults
"
;
import
TestTeacher
from
"
../../Images/defaultimageicon.jpg
"
;
export
default
class
StudentDashboard
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
user_email
:
''
,
user_id
:
''
,
user_name
:
''
,
user_type
:
''
,
isLogged
:
false
}
}
componentDidMount
()
{
const
user_email
=
localStorage
.
getItem
(
"
email
"
);
const
user_id
=
localStorage
.
getItem
(
"
userID
"
);
const
user_name
=
localStorage
.
getItem
(
"
userName
"
);
const
user_type
=
localStorage
.
getItem
(
"
userType
"
);
if
(
user_id
!==
"
"
){
this
.
setState
({
isLogged
:
true
})
}
this
.
setState
({
user_email
:
user_email
,
user_id
:
user_id
,
user_name
:
user_name
,
user_type
:
user_type
})
}
render
()
{
return
(
...
...
@@ -68,22 +106,23 @@ export default class StudentDashboard extends Component {
<
div
className
=
"
widget-content-left
"
>
<
div
className
=
"
btn-group
"
>
<
div
className
=
"
dropdown1
"
>
<
img
width
=
"
42
"
className
=
"
rounded-circle
"
src
=
"
DashboardAssets/images/user.jpg
"
alt
=
""
/>
<
img
src
=
{
TestTeacher
}
className
=
"
rounded-circle
"
style
=
{{
width
:
'
50px
'
,
height
:
'
50px
'
,
float
:
'
left
'
,
margin
:
'
0px
'
}}
/
>
<
i
className
=
"
fa fa-angle-down ml-2 opacity-8
"
/>
<
div
className
=
"
dropdown-content1 dropdown-menu-right
"
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
>
User
Account
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
>
Sign
Out
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/Home
"
);}}
>
Back
To
Home
<
/button
>
<
button
type
=
"
button
"
className
=
"
dropdown-item
"
style
=
{{
color
:
"
red
"
}}
onClick
=
{()
=>
{
window
.
location
.
replace
(
"
/UserLogin
"
);}}
>
Sign
Out
<
/button
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
widget-content-left ml-3 header-user-info
"
>
<
div
className
=
"
widget-heading
"
>
Bandara
Dissanayake
{
this
.
state
.
user_name
}
<
/div
>
<
div
className
=
"
widget-subheading
"
>
Tutor
Student
<
/div
>
<
/div
>
...
...
WebFrontEnd/smartcoach-frontend/src/Images/logout2.png
0 → 100644
View file @
5fccce74
16.5 KB
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