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
3d7f4ace
Commit
3d7f4ace
authored
Jul 25, 2021
by
Hasitha Samarasekara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All Registrations and email sending Done.
parent
c447efb7
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1009 additions
and
175 deletions
+1009
-175
BackEnd/WebBackEnd/.env
BackEnd/WebBackEnd/.env
+3
-1
BackEnd/WebBackEnd/email-config/config.js
BackEnd/WebBackEnd/email-config/config.js
+4
-0
BackEnd/WebBackEnd/email/email.controller.js
BackEnd/WebBackEnd/email/email.controller.js
+66
-0
BackEnd/WebBackEnd/email/email.msgs.js
BackEnd/WebBackEnd/email/email.msgs.js
+7
-0
BackEnd/WebBackEnd/email/email.send.js
BackEnd/WebBackEnd/email/email.send.js
+45
-0
BackEnd/WebBackEnd/email/email.templates.js
BackEnd/WebBackEnd/email/email.templates.js
+20
-0
BackEnd/WebBackEnd/models/institute.user.model.js
BackEnd/WebBackEnd/models/institute.user.model.js
+1
-1
BackEnd/WebBackEnd/models/tutor.user.model.js
BackEnd/WebBackEnd/models/tutor.user.model.js
+5
-3
BackEnd/WebBackEnd/models/userAccount.user.model.js
BackEnd/WebBackEnd/models/userAccount.user.model.js
+20
-0
BackEnd/WebBackEnd/package-lock.json
BackEnd/WebBackEnd/package-lock.json
+6
-0
BackEnd/WebBackEnd/package.json
BackEnd/WebBackEnd/package.json
+3
-0
BackEnd/WebBackEnd/routes/institute.route.js
BackEnd/WebBackEnd/routes/institute.route.js
+112
-16
BackEnd/WebBackEnd/routes/student.route.js
BackEnd/WebBackEnd/routes/student.route.js
+157
-29
BackEnd/WebBackEnd/routes/tutor.route.js
BackEnd/WebBackEnd/routes/tutor.route.js
+152
-25
BackEnd/WebBackEnd/routes/userAccount.route.js
BackEnd/WebBackEnd/routes/userAccount.route.js
+26
-0
BackEnd/WebBackEnd/server.js
BackEnd/WebBackEnd/server.js
+4
-2
WebFrontEnd/smartcoach-frontend/package-lock.json
WebFrontEnd/smartcoach-frontend/package-lock.json
+10
-0
WebFrontEnd/smartcoach-frontend/package.json
WebFrontEnd/smartcoach-frontend/package.json
+2
-1
WebFrontEnd/smartcoach-frontend/src/App.js
WebFrontEnd/smartcoach-frontend/src/App.js
+6
-1
WebFrontEnd/smartcoach-frontend/src/Components/AccountVerified.js
...End/smartcoach-frontend/src/Components/AccountVerified.js
+64
-0
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
+53
-49
WebFrontEnd/smartcoach-frontend/src/Components/SignUp.js
WebFrontEnd/smartcoach-frontend/src/Components/SignUp.js
+207
-47
WebFrontEnd/smartcoach-frontend/src/Components/beforeConfirmation.js
.../smartcoach-frontend/src/Components/beforeConfirmation.js
+36
-0
WebFrontEnd/smartcoach-frontend/src/Images/confirmemail.png
WebFrontEnd/smartcoach-frontend/src/Images/confirmemail.png
+0
-0
WebFrontEnd/smartcoach-frontend/src/Images/verified.png
WebFrontEnd/smartcoach-frontend/src/Images/verified.png
+0
-0
No files found.
BackEnd/WebBackEnd/.env
View file @
3d7f4ace
ATLAS_URI = mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
\ No newline at end of file
ATLAS_URI = mongodb+srv://admin:admin@cluster0.wmb3b.mongodb.net/SmartCoach?retryWrites=true&w=majority
MAIL_USER=onlineshoppingwebsite18@gmail.com
MAIL_PASS=Sliit@123
\ No newline at end of file
BackEnd/WebBackEnd/email-config/config.js
0 → 100644
View file @
3d7f4ace
module
.
exports
=
{
USER
:
'
smartcoach.smteam@gmail.com
'
,
PASS
:
'
Sliit@123
'
}
BackEnd/WebBackEnd/email/email.controller.js
0 → 100644
View file @
3d7f4ace
const
User
=
require
(
'
../models/userAccount.user.model
'
);
const
sendEmail
=
require
(
'
./email.send
'
);
const
msgs
=
require
(
'
./email.msgs
'
);
const
templates
=
require
(
'
./email.templates
'
);
exports
.
collectEmail
=
(
req
,
res
)
=>
{
const
{
email
}
=
req
.
body
User
.
findOne
({
email
})
.
then
(
user
=>
{
// We have a new user! Send them a confirmation email.
if
(
!
user
)
{
User
.
create
({
email
})
.
then
(
newUser
=>
sendEmail
(
newUser
.
email
,
templates
.
confirm
(
newUser
.
_id
)))
.
then
(()
=>
res
.
json
({
msg
:
msgs
.
confirm
}))
.
catch
(
err
=>
console
.
log
(
err
))
}
// We have already seen this email address. But the user has not
// clicked on the confirmation link. Send another confirmation email.
else
if
(
user
&&
!
user
.
confirmed
)
{
sendEmail
(
user
.
email
,
templates
.
confirm
(
user
.
_id
))
.
then
(()
=>
res
.
json
({
msg
:
msgs
.
resend
}))
}
// The user has already confirmed this email address
else
{
res
.
json
({
msg
:
msgs
.
alreadyConfirmed
})
}
})
.
catch
(
err
=>
console
.
log
(
err
))
}
// The callback that is invoked when the user visits the confirmation
// url on the client and a fetch request is sent in componentDidMount.
exports
.
confirmEmail
=
(
req
,
res
)
=>
{
const
{
id
}
=
req
.
params
User
.
findById
(
id
)
.
then
(
user
=>
{
// A user with that id does not exist in the DB. Perhaps some tricky
// user tried to go to a different url than the one provided in the
// confirmation email.
if
(
!
user
)
{
res
.
json
({
msg
:
msgs
.
couldNotFind
})
}
// The user exists but has not been confirmed. We need to confirm this
// user and let them know their email address has been confirmed.
else
if
(
user
&&
!
user
.
confirmed
)
{
User
.
findByIdAndUpdate
(
id
,
{
confirmed
:
true
})
.
then
(()
=>
res
.
json
({
msg
:
msgs
.
confirmed
}))
.
catch
(
err
=>
console
.
log
(
err
))
}
// The user has already confirmed this email address.
else
{
res
.
json
({
msg
:
msgs
.
alreadyConfirmed
})
}
})
.
catch
(
err
=>
console
.
log
(
err
))
}
\ No newline at end of file
BackEnd/WebBackEnd/email/email.msgs.js
0 → 100644
View file @
3d7f4ace
module
.
exports
=
{
confirm
:
'
Email sent, please check your inbox to confirm
'
,
confirmed
:
'
Your email is confirmed!
'
,
resend
:
'
Confirmation email resent, maybe check your spam?
'
,
couldNotFind
:
'
Could not find you!
'
,
alreadyConfirmed
:
'
Your email was already confirmed
'
}
\ No newline at end of file
BackEnd/WebBackEnd/email/email.send.js
0 → 100644
View file @
3d7f4ace
const
nodemailer
=
require
(
'
nodemailer
'
)
// The credentials for the email account you want to send mail from.
const
credentials
=
{
host
:
'
smtp.gmail.com
'
,
port
:
465
,
secure
:
true
,
auth
:
{
// These environment variables will be pulled from the .env file
user
:
process
.
env
.
MAIL_USER
,
pass
:
process
.
env
.
MAIL_PASS
}
}
// Getting Nodemailer all setup with the credentials for when the 'sendEmail()'
// function is called.
const
transporter
=
nodemailer
.
createTransport
(
credentials
)
// exporting an 'async' function here allows 'await' to be used
// as the return value of this function.
module
.
exports
=
async
(
to
,
content
)
=>
{
// The from and to addresses for the email that is about to be sent.
const
contacts
=
{
from
:
process
.
env
.
MAIL_USER
,
to
}
// Combining the content and contacts into a single object that can
// be passed to Nodemailer.
const
email
=
Object
.
assign
({},
content
,
contacts
)
// This file is imported into the controller as 'sendEmail'. Because
// 'transporter.sendMail()' below returns a promise we can write code like this
// in the contoller when we are using the sendEmail() function.
//
// sendEmail()
// .then(() => doSomethingElse())
//
// If you are running into errors getting Nodemailer working, wrap the following
// line in a try/catch. Most likely is not loading the credentials properly in
// the .env file or failing to allow unsafe apps in your gmail settings.
await
transporter
.
sendMail
(
email
)
}
\ No newline at end of file
BackEnd/WebBackEnd/email/email.templates.js
0 → 100644
View file @
3d7f4ace
const
{
CLIENT_ORIGIN
}
=
'
http://localhost:3000/beforeConfirm
'
// This file is exporting an Object with a single key/value pair.
// However, because this is not a part of the logic of the application
// it makes sense to abstract it to another file. Plus, it is now easily
// extensible if the application needs to send different email templates
// (eg. unsubscribe) in the future.
module
.
exports
=
{
confirm
:
id
=>
({
subject
:
'
React Confirm Email
'
,
html
:
`
<a href='
${
CLIENT_ORIGIN
}
/confirm/
${
id
}
'>
click to confirm email
</a>
`
,
text
:
`Copy and paste this link:
${
CLIENT_ORIGIN
}
/confirm/
${
id
}
`
})
}
\ No newline at end of file
BackEnd/WebBackEnd/models/institute.user.model.js
View file @
3d7f4ace
...
...
@@ -5,7 +5,7 @@ const Schema = mongoose.Schema;
const
userSchema
=
new
Schema
({
institute_name
:{
type
:
String
,
required
:
true
},
institute_email
:
{
type
:
String
,
required
:
true
},
institute_phones
:
{
type
:
String
,
required
:
true
}
,
institute_phones
:
[{
type
:
String
,
required
:
true
}]
,
institute_address
:{
type
:
String
,
required
:
true
},
institute_city
:{
type
:
String
,
required
:
true
},
institute_password
:{
type
:
String
,
required
:
true
},
...
...
BackEnd/WebBackEnd/models/tutor.user.model.js
View file @
3d7f4ace
...
...
@@ -13,12 +13,14 @@ const userSchema = new Schema({
tutor_status
:{
type
:
String
},
tutor_image
:{
type
:
String
},
tutor_Stream
:{
type
:
String
},
tutor_subjects
:{
type
:
String
},
tutor_class_types
:{
type
:
String
},
tutor_subjects
:[{
type
:
String
}],
isOnlineClass
:{
type
:
Boolean
},
isHomeVisit
:{
type
:
Boolean
},
isInstitute
:{
type
:
Boolean
},
tutor_main_district
:{
type
:
String
},
tutor_main_city
:{
type
:
String
},
tutor_medium
:{
type
:
String
},
tutor_instituteID
:{
type
:
String
}
,
tutor_instituteID
List
:[{
type
:
String
}]
,
},
{
timestamps
:
true
,
});
...
...
BackEnd/WebBackEnd/models/userAccount.user.model.js
0 → 100644
View file @
3d7f4ace
const
mongoose
=
require
(
'
mongoose
'
);
const
Schema
=
mongoose
.
Schema
;
const
userSchema
=
new
Schema
({
user_id
:{
type
:
String
,
required
:
true
},
user_nic
:{
type
:
String
,
required
:
false
},
user_email
:
{
type
:
String
,
required
:
true
},
user_password
:{
type
:
String
,
required
:
true
},
user_type
:{
type
:
String
,
required
:
true
},
confirmed
:
{
type
:
Boolean
,
default
:
false
}
});
const
UserAccount
=
mongoose
.
model
(
'
UserAccount
'
,
userSchema
);
module
.
exports
=
UserAccount
;
\ No newline at end of file
BackEnd/WebBackEnd/package-lock.json
View file @
3d7f4ace
...
...
@@ -392,6 +392,12 @@
"resolved"
:
"https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz"
,
"integrity"
:
"sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"nodemailer"
:
{
"version"
:
"6.6.2"
,
"resolved"
:
"https://registry.npmjs.org/nodemailer/-/nodemailer-6.6.2.tgz"
,
"integrity"
:
"sha512-YSzu7TLbI+bsjCis/TZlAXBoM4y93HhlIgo0P5oiA2ua9Z4k+E2Fod//ybIzdJxOlXGRcHIh/WaeCBehvxZb/Q=="
,
"dev"
:
true
},
"object-assign"
:
{
"version"
:
"4.1.1"
,
"resolved"
:
"https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
,
...
...
BackEnd/WebBackEnd/package.json
View file @
3d7f4ace
...
...
@@ -14,5 +14,8 @@
"dotenv"
:
"^10.0.0"
,
"express"
:
"^4.17.1"
,
"mongoose"
:
"^5.12.15"
},
"devDependencies"
:
{
"nodemailer"
:
"^6.6.2"
}
}
BackEnd/WebBackEnd/routes/institute.route.js
View file @
3d7f4ace
const
router
=
require
(
'
express
'
).
Router
();
let
institute
=
require
(
'
../models/institute.user.model
'
);
let
userAccount
=
require
(
'
../models/userAccount.user.model
'
);
const
nodemailer
=
require
(
'
nodemailer
'
);
const
cred
=
require
(
'
../email-config/config
'
);
////////////////////////////////////////////////////////////////////////////////////////
var
transport
=
{
host
:
'
smtp.gmail.com
'
,
auth
:
{
user
:
cred
.
USER
,
pass
:
cred
.
PASS
}
}
var
transporter
=
nodemailer
.
createTransport
(
transport
);
transporter
.
verify
((
error
,
success
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
}
else
{
console
.
log
(
'
Server is ready to take messages of Institute
'
);
}
});
/////////////////////////////////////////////////////////////////////////////////////////////
router
.
route
(
'
/
'
).
get
((
req
,
res
)
=>
{
institute
.
find
()
.
then
(
students
=>
res
.
json
(
student
s
))
.
then
(
Institutes
=>
res
.
json
(
Institute
s
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Eroor:
'
+
err
));
});
router
.
route
(
'
/add
'
).
post
((
req
,
res
)
=>
{
router
.
route
(
'
/add
'
).
post
(
async
(
req
,
res
)
=>
{
const
institute_name
=
req
.
body
.
institute_name
;
const
institute_email
=
req
.
body
.
institute_email
;
const
institute_phones
=
req
.
body
.
institute_phones
;
...
...
@@ -18,20 +46,88 @@ router.route('/add').post((req,res) =>{
const
institute_image
=
req
.
body
.
institute_image
;
const
newInstitute
=
new
institute
({
institute_name
,
institute_email
,
institute_phones
,
institute_address
,
institute_city
,
institute_password
,
institute_registrationNo
,
institute_image
});
newInstitute
.
save
()
.
then
(()
=>
res
.
json
(
'
Institute Successfully Added....
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
//checking if the user is already exist in the database
const
user
=
await
institute
.
findOne
({
institute_email
:
req
.
body
.
institute_email
})
if
(
!
user
){
const
newInstitute
=
new
institute
({
institute_name
,
institute_email
,
institute_phones
,
institute_address
,
institute_city
,
institute_password
,
institute_registrationNo
,
institute_image
});
newInstitute
.
save
()
.
then
(
Institute
=>
{
const
user_id
=
Institute
.
id
.
toString
();
const
user_nic
=
""
;
const
user_email
=
req
.
body
.
institute_email
;
const
user_password
=
req
.
body
.
institute_password
;
const
user_type
=
"
Institute
"
;
const
newUser
=
new
userAccount
({
user_id
,
user_nic
,
user_email
,
user_password
,
user_type
});
newUser
.
save
()
.
then
(
newUser
=>
{
////////////////////////////////////////////////////////////////////////////////////
const
content
=
`
Hi
${
institute_name
}
,\n
You are Create a Institute Account on SmartCoach.\n
You can verify your email address click on 'http://localhost:3000/AccountVerified/
${
newUser
.
id
}
'
Used institute email address as the username :
${
user_email
}
Used given password as the password
Thank You,
Team SmartCoach
`
;
var
mail
=
{
from
:
institute_name
,
to
:
user_email
,
subject
:
'
Email Verification - Institute
'
,
text
:
content
}
transporter
.
sendMail
(
mail
,
(
err
,
data
)
=>
{
if
(
err
)
{
res
.
json
({
msg
:
'
fail
'
})
}
else
{
res
.
json
({
msg
:
'
success
'
})
}
})
;
/////////////////////////////////////////////////////////////////////////////////////
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
}
else
{
return
res
.
status
(
500
).
json
(
'
Email already exit
'
);
}
});
...
...
BackEnd/WebBackEnd/routes/student.route.js
View file @
3d7f4ace
const
router
=
require
(
'
express
'
).
Router
();
let
student
=
require
(
'
../models/student.user.model
'
);
let
userAccount
=
require
(
'
../models/userAccount.user.model
'
);
const
nodemailer
=
require
(
'
nodemailer
'
);
const
cred
=
require
(
'
../email-config/config
'
);
////////////////////////////////////////////////////////////////////////////////////////
var
transport
=
{
host
:
'
smtp.gmail.com
'
,
auth
:
{
user
:
cred
.
USER
,
pass
:
cred
.
PASS
}
}
var
transporter
=
nodemailer
.
createTransport
(
transport
);
transporter
.
verify
((
error
,
success
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
}
else
{
console
.
log
(
'
Server is ready to take messages to Student
'
);
}
});
/////////////////////////////////////////////////////////////////////////////////////////////
router
.
route
(
'
/
'
).
get
((
req
,
res
)
=>
{
student
.
find
()
...
...
@@ -7,35 +31,139 @@ router.route('/').get((req,res) =>{
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Eroor:
'
+
err
));
});
router
.
route
(
'
/add
'
).
post
((
req
,
res
)
=>
{
const
student_name
=
req
.
body
.
student_name
;
const
student_nic
=
req
.
body
.
student_nic
;
const
student_email
=
req
.
body
.
student_email
;
const
student_phone
=
req
.
body
.
student_phone
;
const
student_address
=
req
.
body
.
student_address
;
const
student_password
=
req
.
body
.
student_password
;
const
student_gender
=
req
.
body
.
student_gender
;
const
student_image
=
req
.
body
.
student_image
;
const
guardian_name
=
req
.
body
.
guardian_name
;
const
guardian_email
=
req
.
body
.
guardian_email
;
const
guardian_relationship
=
req
.
body
.
guardian_relationship
;
const
newStudent
=
new
student
({
student_name
,
student_nic
,
student_email
,
student_phone
,
student_address
,
student_password
,
student_gender
,
student_image
,
guardian_name
,
guardian_email
,
guardian_relationship
});
newStudent
.
save
()
.
then
(()
=>
res
.
json
(
'
Student Successfully Added....
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
router
.
route
(
'
/add
'
).
post
(
async
(
req
,
res
)
=>
{
//checking if the user is already exist in the database
const
user
=
await
student
.
findOne
({
student_email
:
req
.
body
.
student_email
})
if
(
!
user
){
const
student_name
=
req
.
body
.
student_name
;
const
student_nic
=
req
.
body
.
student_nic
;
const
student_email
=
req
.
body
.
student_email
;
const
student_phone
=
req
.
body
.
student_phone
;
const
student_address
=
req
.
body
.
student_address
;
const
student_password
=
req
.
body
.
student_password
;
const
student_gender
=
req
.
body
.
student_gender
;
const
student_image
=
req
.
body
.
student_image
;
const
guardian_name
=
req
.
body
.
guardian_name
;
const
guardian_email
=
req
.
body
.
guardian_email
;
const
guardian_relationship
=
req
.
body
.
guardian_relationship
;
const
newStudent
=
new
student
({
student_name
,
student_nic
,
student_email
,
student_phone
,
student_address
,
student_password
,
student_gender
,
student_image
,
guardian_name
,
guardian_email
,
guardian_relationship
});
newStudent
.
save
()
.
then
(
Student
=>
{
const
user_id
=
Student
.
id
.
toString
();
const
user_nic
=
student_nic
;
const
user_email
=
student_email
;
const
user_password
=
student_password
;
const
user_type
=
"
Student
"
;
const
newUser
=
new
userAccount
({
user_id
,
user_nic
,
user_email
,
user_password
,
user_type
});
newUser
.
save
()
.
then
(
newUser
=>
{
////////////////////////////////////////////////////////////////////////////////////
const
content
=
`
Hi
${
student_name
}
,\n
You are Create a Student Account on SmartCoach.\n
You can verify your email address click on 'http://localhost:3000/AccountVerified/
${
newUser
.
id
}
'
Used your email address as the username :
${
user_email
}
Used given password as the password
Thank You,
Team SmartCoach
`
;
var
mail
=
{
from
:
student_name
,
to
:
user_email
,
subject
:
'
Email Verification - Student
'
,
text
:
content
}
transporter
.
sendMail
(
mail
,
(
err
,
data
)
=>
{
if
(
err
)
{
res
.
json
({
msg
:
'
fail
'
})
}
else
{
res
.
json
({
msg
:
'
success
'
})
}
})
;
const
content_guardian
=
`
Hi
${
guardian_name
}
,\n
Your student
${
student_name
}
is Create a Student Account on SmartCoach.\n
You can know student progress through the email.
We will send Student attendance, Quiz marks, Assignment Marks and other details through this email.
Thank You,
Team SmartCoach
`
;
var
mail_guardian
=
{
from
:
guardian_name
,
to
:
guardian_email
,
subject
:
'
Student Information on SmartCoach
'
,
text
:
content_guardian
}
transporter
.
sendMail
(
mail_guardian
,
(
err
,
data
)
=>
{
if
(
err
)
{
res
.
json
({
msg
:
'
fail
'
})
}
else
{
res
.
json
({
msg
:
'
success
'
})
}
})
;
/////////////////////////////////////////////////////////////////////////////////////
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
}
else
{
return
res
.
status
(
500
).
json
(
'
Email already exit
'
);
}
});
...
...
BackEnd/WebBackEnd/routes/tutor.route.js
View file @
3d7f4ace
const
router
=
require
(
'
express
'
).
Router
();
let
tutor
=
require
(
'
../models/tutor.user.model
'
);
let
userAccount
=
require
(
'
../models/userAccount.user.model
'
);
const
nodemailer
=
require
(
'
nodemailer
'
);
const
cred
=
require
(
'
../email-config/config
'
);
////////////////////////////////////////////////////////////////////////////////////////
var
transport
=
{
host
:
'
smtp.gmail.com
'
,
auth
:
{
user
:
cred
.
USER
,
pass
:
cred
.
PASS
}
}
var
transporter
=
nodemailer
.
createTransport
(
transport
);
transporter
.
verify
((
error
,
success
)
=>
{
if
(
error
)
{
console
.
log
(
error
);
}
else
{
console
.
log
(
'
Server is ready to take messages of User
'
);
}
});
/////////////////////////////////////////////////////////////////////////////////////////////
router
.
route
(
'
/
'
).
get
((
req
,
res
)
=>
{
tutor
.
find
()
...
...
@@ -7,7 +33,9 @@ router.route('/').get((req,res) =>{
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Eroor:
'
+
err
));
});
router
.
route
(
'
/add
'
).
post
((
req
,
res
)
=>
{
router
.
route
(
'
/add
'
).
post
(
async
(
req
,
res
)
=>
{
const
tutor_name
=
req
.
body
.
tutor_name
;
const
tutor_nic
=
req
.
body
.
tutor_nic
;
const
tutor_email
=
req
.
body
.
tutor_email
;
...
...
@@ -19,35 +47,134 @@ router.route('/add').post((req,res) =>{
const
tutor_image
=
req
.
body
.
tutor_image
;
const
tutor_Stream
=
req
.
body
.
tutor_Stream
;
const
tutor_subjects
=
req
.
body
.
tutor_subjects
;
const
tutor_class_types
=
req
.
body
.
tutor_class_types
;
const
isOnlineClass
=
req
.
body
.
isOnlineClass
;
const
isHomeVisit
=
req
.
body
.
isHomeVisit
;
const
isInstitute
=
req
.
body
.
isInstitute
;
const
tutor_main_district
=
req
.
body
.
tutor_main_district
;
const
tutor_main_city
=
req
.
body
.
tutor_main_city
;
const
tutor_medium
=
req
.
body
.
tutor_medium
;
const
tutor_instituteID
=
req
.
body
.
tutor_instituteID
;
const
newTutor
=
new
tutor
({
tutor_name
,
tutor_nic
,
tutor_email
,
tutor_phone
,
tutor_address
,
tutor_password
,
tutor_gender
,
tutor_status
,
tutor_image
,
tutor_Stream
,
tutor_subjects
,
tutor_class_types
,
tutor_main_district
,
tutor_main_city
,
tutor_medium
,
tutor_instituteID
});
newTutor
.
save
()
.
then
(()
=>
res
.
json
(
'
Tutor Successfully Added....
'
))
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
const
tutor_instituteIDList
=
req
.
body
.
tutor_instituteIDList
;
//checking if the user is already exist in the database
const
user
=
await
tutor
.
findOne
({
tutor_email
:
req
.
body
.
tutor_email
})
if
(
!
user
){
const
newTutor
=
new
tutor
({
tutor_name
,
tutor_nic
,
tutor_email
,
tutor_phone
,
tutor_address
,
tutor_password
,
tutor_gender
,
tutor_status
,
tutor_image
,
tutor_Stream
,
tutor_subjects
,
isOnlineClass
,
isHomeVisit
,
isInstitute
,
tutor_main_district
,
tutor_main_city
,
tutor_medium
,
tutor_instituteIDList
});
newTutor
.
save
()
.
then
(
tutor
=>
{
console
.
log
(
"
Inside the New User
"
)
console
.
log
(
tutor
.
id
)
const
user_id
=
tutor
.
id
.
toString
();
const
user_nic
=
req
.
body
.
tutor_nic
;
const
user_email
=
req
.
body
.
tutor_email
;
const
user_password
=
req
.
body
.
tutor_password
;
const
user_type
=
"
Tutor
"
;
const
newUser
=
new
userAccount
({
user_id
,
user_nic
,
user_email
,
user_password
,
user_type
});
console
.
log
(
newUser
);
newUser
.
save
()
.
then
(
newUser
=>
{
console
.
log
(
"
Inside the Email Send part
"
)
////////////////////////////////////////////////////////////////////////////////////
const
content
=
`
Hi
${
tutor_name
}
,\n
You are Create a Tutor Account on SmartCoach.\n
You can verify your email address click on 'http://localhost:3000/AccountVerified/
${
newUser
.
id
}
'
Used your email address as username :
${
user_email
}
Thank You,
Team SmartCoach
`
;
var
mail
=
{
from
:
tutor_name
,
to
:
user_email
,
subject
:
'
Email Verification - Tutor
'
,
text
:
content
}
transporter
.
sendMail
(
mail
,
(
err
,
data
)
=>
{
if
(
err
)
{
res
.
json
({
msg
:
'
fail
'
})
}
else
{
res
.
json
({
msg
:
'
success
'
})
}
})
;
/////////////////////////////////////////////////////////////////////////////////////
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
// res.json('Tutor Successfully Added....');
})
.
catch
(
err
=>
res
.
status
(
400
).
json
(
'
Error:
'
+
err
));
}
else
{
return
res
.
status
(
500
).
json
(
'
Email already exit
'
);
}
});
// router.route('/update/:id').post((req,res) =>{
// userAccount.findById(req.params.id, function(err, details){
// if(!details){
// req.status(404).send("data is not found");
// }
// else {
// details.confirmed = true;
//
// details.save().then( () => {
// res.json('Item update!');
// })
// .catch(err => {
// res.status(400).send("Update not possible");
// });
// }
// })
// });
module
.
exports
=
router
;
BackEnd/WebBackEnd/routes/userAccount.route.js
0 → 100644
View file @
3d7f4ace
const
router
=
require
(
'
express
'
).
Router
();
let
userAccount
=
require
(
'
../models/userAccount.user.model
'
);
router
.
route
(
'
/update/:id
'
).
post
((
req
,
res
)
=>
{
userAccount
.
findById
(
req
.
params
.
id
,
function
(
err
,
details
){
if
(
!
details
){
req
.
status
(
404
).
send
(
"
data is not found
"
);
}
else
{
details
.
confirmed
=
true
;
details
.
save
().
then
(
()
=>
{
res
.
json
(
'
Item update!
'
);
})
.
catch
(
err
=>
{
res
.
status
(
400
).
send
(
"
Update not possible
"
);
});
}
})
});
module
.
exports
=
router
;
BackEnd/WebBackEnd/server.js
View file @
3d7f4ace
...
...
@@ -8,7 +8,8 @@ require('dotenv').config();
const
app
=
express
();
const
port
=
process
.
env
.
PORT
||
5000
;
app
.
use
(
cors
());
app
.
use
(
cors
({}));
app
.
use
(
express
.
json
());
const
uri
=
process
.
env
.
ATLAS_URI
;
...
...
@@ -22,11 +23,12 @@ connection.once('open',() => {
const
studentRouter
=
require
(
'
./routes/student.route
'
);
const
tutorRouter
=
require
(
'
./routes/tutor.route
'
);
const
instituteRouter
=
require
(
'
./routes/institute.route
'
);
const
userAccount
=
require
(
'
./routes/userAccount.route
'
);
app
.
use
(
'
/studentSingUp
'
,
studentRouter
);
app
.
use
(
'
/tutorSingUp
'
,
tutorRouter
);
app
.
use
(
'
/instituteSingUp
'
,
instituteRouter
);
app
.
use
(
'
/userAccount
'
,
userAccount
);
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`Server is running on Port:
${
port
}
`
);
...
...
WebFrontEnd/smartcoach-frontend/package-lock.json
View file @
3d7f4ace
...
...
@@ -12462,6 +12462,16 @@
"resolved"
:
"https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz"
,
"integrity"
:
"sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"react-notify-toast"
:
{
"version"
:
"0.5.1"
,
"resolved"
:
"https://registry.npmjs.org/react-notify-toast/-/react-notify-toast-0.5.1.tgz"
,
"integrity"
:
"sha512-VCTuvykAj3IBVX1ecVRxpo8csBJVGhKdJF4qk8c59nxbE4FPWmNpSAzyAMNNd0Mnxfwk8DA6Z0x8C/S0wCbbqg=="
,
"dev"
:
true
,
"requires"
:
{
"object-assign"
:
"^4.0.0"
,
"prop-types"
:
"^15.5.8"
}
},
"react-refresh"
:
{
"version"
:
"0.8.3"
,
"resolved"
:
"https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz"
,
...
...
WebFrontEnd/smartcoach-frontend/package.json
View file @
3d7f4ace
...
...
@@ -40,6 +40,7 @@
]
},
"devDependencies"
:
{
"axios"
:
"^0.21.1"
"axios"
:
"^0.21.1"
,
"react-notify-toast"
:
"^0.5.1"
}
}
WebFrontEnd/smartcoach-frontend/src/App.js
View file @
3d7f4ace
import
'
./App.css
'
;
import
'
bootstrap/dist/css/bootstrap.min.css
'
;
import
{
BrowserRouter
as
Router
,
Route
}
from
"
react-router-dom
"
;
//Pages
...
...
@@ -8,15 +9,19 @@ import Login from "./Components/Login";
import
ItemNav
from
"
./Components/Navbar
"
;
import
Home
from
"
./Components/Home
"
;
import
SignUp
from
"
./Components/SignUp
"
;
import
beforeConfirmation
from
"
./Components/beforeConfirmation
"
;
import
VerifiedAccount
from
"
./Components/AccountVerified
"
;
function
App
()
{
return
(
<
Router
>
<
div
className
=
"
App
"
>
<
ItemNav
/>
<
Route
path
=
"
/UserLogin
"
exact
component
=
{
Login
}
/
>
<
Route
path
=
"
/Home
"
exact
component
=
{
Home
}
/
>
<
Route
path
=
"
/SignUp
"
exact
component
=
{
SignUp
}
/
>
<
Route
path
=
"
/beforeConfirm
"
exact
component
=
{
beforeConfirmation
}
/
>
<
Route
path
=
"
/AccountVerified/:id
"
exact
component
=
{
VerifiedAccount
}
/
>
<
/div
>
<
/Router
>
);
...
...
WebFrontEnd/smartcoach-frontend/src/Components/AccountVerified.js
0 → 100644
View file @
3d7f4ace
import
React
,
{
Component
}
from
"
react
"
;
import
VerifiedIcon
from
"
../Images/verified.png
"
;
import
axios
from
"
axios
"
;
import
*
as
configs
from
"
../Config/config
"
;
export
default
class
AccountVerified
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
id
:
''
};
}
componentDidMount
()
{
console
.
log
(
this
.
props
.
match
.
params
.
id
)
this
.
setState
({
id
:
this
.
props
.
match
.
params
.
id
},
()
=>
{
axios
.
post
(
configs
.
BASE_URL
+
'
/userAccount/update/
'
+
this
.
state
.
id
)
})
}
render
()
{
return
(
<
div
className
=
"
container
"
style
=
{{
padding
:
'
10px
'
}}
>
<
div
style
=
{{
width
:
'
50%
'
,
margin
:
'
auto
'
,
marginTop
:
'
7%
'
,
padding
:
'
10px
'
,
paddingBottom
:
'
30px
'
,
border
:
'
solid
'
,
borderColor
:
'
#216E9B
'
}}
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
contents
'
}}
>
<
img
src
=
{
VerifiedIcon
}
style
=
{{
width
:
'
80px
'
,
height
:
'
90px
'
}}
/
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
,
marginBottom
:
'
0px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
h2
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#265077
'
,
margin
:
'
0px
'
,
textAlign
:
'
center
'
}}
>
Your
Email
is
Verified
<
/h2
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
5px
'
,
marginBottom
:
'
0px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
br
/>
<
span
>
Your
Account
has
been
successfully
verified
.
Thank
you
for
join
with
SmartCoach
.
Now
you
can
start
tutoring
in
SmartCoach
.
<
/span
>
<
br
/>
<
span
>
You
can
login
with
your
credentials
.
<
/span
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
20px
'
,
marginBottom
:
'
0px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
a
href
=
"
/UserLogin
"
type
=
"
submit
"
className
=
"
profile-edit-btn nav-link btn btn-primary
"
name
=
"
btnAddMore
"
style
=
{{
marginTop
:
'
20px
'
,
marginBottom
:
'
30px
'
,
width
:
'
50%
'
,
backgroundColor
:
'
#265077
'
,
borderColor
:
'
#216E9B
'
,
fontSize
:
'
12px
'
}}
>
Sign
In
<
/a
>
<
/div
>
<
/div
>
<
/div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Components/Login.js
View file @
3d7f4ace
import
React
,
{
Component
}
from
"
react
"
;
import
ItemNav
from
"
./Navbar
"
;
export
default
class
Login
extends
Component
{
...
...
@@ -62,69 +63,72 @@ export default class Login extends Component{
render
()
{
return
(
<
div
className
=
"
container
"
style
=
{{
padding
:
'
10px
'
}}
>
<
div
>
<
div
style
=
{{
width
:
'
30%
'
,
margin
:
'
auto
'
,
marginTop
:
'
7%
'
,
padding
:
'
0px
'
,
paddingBottom
:
'
30px
'
,
border
:
'
solid
'
,
borderColor
:
'
#216E9B
'
}}
>
<
form
onSubmit
=
{
this
.
onSubmit
}
id
=
"
login
"
name
=
"
login
"
className
=
"
login
"
>
<
div
className
=
"
row
"
>
<
br
/>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
h3
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#265077
'
,
margin
:
'
20px
'
,
textAlign
:
'
center
'
}}
><
b
>
Login
<
/b></
h3
>
<
/div
>
<
div
>
<
div
className
=
"
row
"
style
=
{{
width
:
'
100%
'
,
margin
:
'
0px
'
}}
>
<
ItemNav
/>
<
/div
>
<
div
className
=
"
container
"
style
=
{{
padding
:
'
10px
'
}}
>
<
div
style
=
{{
width
:
'
35%
'
,
margin
:
'
auto
'
,
marginTop
:
'
7%
'
,
padding
:
'
0px
'
,
paddingBottom
:
'
30px
'
,
border
:
'
solid
'
,
borderColor
:
'
#216E9B
'
}}
>
<
form
onSubmit
=
{
this
.
onSubmit
}
id
=
"
login
"
name
=
"
login
"
className
=
"
login
"
>
<
div
className
=
"
row
"
>
<
br
/>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
h3
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#265077
'
,
margin
:
'
20px
'
,
textAlign
:
'
center
'
}}
><
b
>
Login
<
/b></
h3
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
label
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#A9BCC8
'
}}
>
Use
your
credentials
to
login
<
/label
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
margin
:
'
5px
'
}}
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
,
marginBottom
:
'
10px
'
}}
>
<
div
className
=
"
col-1
"
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
label
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#A9BCC8
'
}}
>
Use
your
credentials
to
login
<
/label
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
margin
:
'
5px
'
}}
>
<
/div
>
<
div
className
=
"
col-10
"
>
<
input
type
=
"
email
"
id
=
"
email
"
className
=
"
form-control
"
placeholder
=
"
UserName
"
onChange
=
{
this
.
onChangeEmail
}
required
/>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
,
marginBottom
:
'
10px
'
}}
>
<
div
className
=
"
col-1
"
>
<
/div
>
<
div
className
=
"
col-10
"
>
<
input
type
=
"
email
"
id
=
"
email
"
className
=
"
form-control
"
placeholder
=
"
UserName
"
onChange
=
{
this
.
onChangeEmail
}
required
/>
<
/div
>
<
div
className
=
"
col-1
"
>
<
/div
>
<
/div
>
<
div
className
=
"
col-1
"
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
,
marginBottom
:
'
10px
'
}}
>
<
div
className
=
"
col-1
"
>
<
/div
>
<
div
className
=
"
col-10
"
>
<
input
type
=
"
password
"
id
=
"
password
"
className
=
"
form-control
"
placeholder
=
"
Password
"
onChange
=
{
this
.
onChangePassword
}
required
/>
<
/div
>
<
div
className
=
"
col-1
"
>
<
/div
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
10px
'
,
marginBottom
:
'
10px
'
}}
>
<
div
className
=
"
col-1
"
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
label
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#2353BA
'
}}
>
Forgot
Password
???
<
/label
>
<
/div
>
<
div
className
=
"
col-10
"
>
<
input
type
=
"
password
"
id
=
"
password
"
className
=
"
form-control
"
placeholder
=
"
Password
"
onChange
=
{
this
.
onChangePassword
}
required
/
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
5px
'
,
marginBottom
:
'
5px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
button
type
=
"
submit
"
className
=
"
btn btn-primary
"
style
=
{{
width
:
'
50%
'
,
marginTop
:
'
0px
'
,
backgroundColor
:
'
#265077
'
,
borderColor
:
'
#216E9B
'
}}
><
b
>
Sign
In
<
/b></
button
>
<
/div
>
<
div
className
=
"
col-1
"
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
0px
'
,
marginBottom
:
'
5px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
a
href
=
"
/SignUp
"
type
=
"
submit
"
className
=
"
profile-edit-btn nav-link btn btn-primary
"
name
=
"
btnAddMore
"
style
=
{{
marginTop
:
'
0px
'
,
marginBottom
:
'
20px
'
,
width
:
'
50%
'
,
backgroundColor
:
'
#2D5F5D
'
,
borderColor
:
'
#216E9B
'
,
fontSize
:
'
12px
'
}}
>
Sign
Up
<
/a
>
<
/div
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
label
style
=
{{
fontFamily
:
'
emoji
'
,
color
:
'
#2353BA
'
}}
>
Forgot
Password
???
<
/label
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
5px
'
,
marginBottom
:
'
5px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
button
type
=
"
submit
"
className
=
"
btn btn-primary
"
style
=
{{
width
:
'
50%
'
,
marginTop
:
'
0px
'
,
backgroundColor
:
'
#265077
'
,
borderColor
:
'
#216E9B
'
}}
><
b
>
Sign
In
<
/b></
button
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
marginTop
:
'
0px
'
,
marginBottom
:
'
5px
'
,
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
<
a
href
=
"
/SignUp
"
type
=
"
submit
"
className
=
"
profile-edit-btn nav-link btn btn-primary
"
name
=
"
btnAddMore
"
style
=
{{
marginTop
:
'
0px
'
,
marginBottom
:
'
20px
'
,
width
:
'
50%
'
,
backgroundColor
:
'
#2D5F5D
'
,
borderColor
:
'
#216E9B
'
,
fontSize
:
'
12px
'
}}
>
Sign
Up
<
/a
>
<
/div
>
<
/form
>
<
/div
>
<
/form
>
<
/div
>
<
/div
>
<
/div
>
)
...
...
WebFrontEnd/smartcoach-frontend/src/Components/SignUp.js
View file @
3d7f4ace
This diff is collapsed.
Click to expand it.
WebFrontEnd/smartcoach-frontend/src/Components/beforeConfirmation.js
0 → 100644
View file @
3d7f4ace
import
React
,
{
Component
}
from
"
react
"
;
import
ItemNav
from
"
./Navbar
"
;
import
ConfirmEmail
from
"
../Images/confirmemail.png
"
;
export
default
class
beforeConfirmation
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
};
}
render
()
{
return
(
<
div
>
<
div
className
=
"
row
"
style
=
{{
width
:
'
100%
'
}}
>
<
ItemNav
/>
<
/div
>
<
div
style
=
{{
width
:
'
50%
'
,
margin
:
'
auto
'
,
marginTop
:
'
7%
'
,
padding
:
'
10px
'
,
paddingBottom
:
'
30px
'
,
border
:
'
solid
'
,
borderColor
:
'
#216E9B
'
}}
>
<
div
className
=
"
row
"
style
=
{{
display
:
'
contents
'
}}
>
<
img
src
=
{
ConfirmEmail
}
style
=
{{
width
:
'
300
'
,
height
:
'
300px
'
}}
/
>
<
/div
>
<
div
className
=
"
row
"
style
=
{{
padding
:
'
40px
'
}}
>
<
span
>
Your
Account
has
been
successfully
registered
.
To
complete
the
process
please
check
your
email
for
a
validation
request
<
/span
>
<
/div
>
<
/div
>
<
/div
>
)
}
}
\ No newline at end of file
WebFrontEnd/smartcoach-frontend/src/Images/confirmemail.png
0 → 100644
View file @
3d7f4ace
35.9 KB
WebFrontEnd/smartcoach-frontend/src/Images/verified.png
0 → 100644
View file @
3d7f4ace
31.2 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