Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 16
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
22_23-J 16
22_23-J 16
Commits
56cef06d
Commit
56cef06d
authored
May 17, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login endpoints at the backend
parent
2bbbbe66
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
775 additions
and
4 deletions
+775
-4
ExpressBackend/package-lock.json
ExpressBackend/package-lock.json
+669
-4
ExpressBackend/package.json
ExpressBackend/package.json
+1
-0
ExpressBackend/route/patient-routes/login-route.js
ExpressBackend/route/patient-routes/login-route.js
+51
-0
ExpressBackend/route/practitioner-routes/login-route.js
ExpressBackend/route/practitioner-routes/login-route.js
+48
-0
ExpressBackend/server.js
ExpressBackend/server.js
+6
-0
No files found.
ExpressBackend/package-lock.json
View file @
56cef06d
This diff is collapsed.
Click to expand it.
ExpressBackend/package.json
View file @
56cef06d
...
...
@@ -15,6 +15,7 @@
"license"
:
"ISC"
,
"dependencies"
:
{
"axios"
:
"^1.2.2"
,
"bcrypt"
:
"^5.1.0"
,
"cors"
:
"^2.8.5"
,
"crypto-js"
:
"^4.1.1"
,
"express"
:
"^4.18.2"
,
...
...
ExpressBackend/route/patient-routes/login-route.js
0 → 100644
View file @
56cef06d
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
Patient
=
require
(
"
./../../model/patient/patient
"
);
const
DecryptWithServerKey
=
require
(
"
./../../services/decryptionservice
"
);
const
bcrypt
=
require
(
"
bcrypt
"
);
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
const
username
=
req
.
body
.
username
;
const
password
=
req
.
body
.
password
;
const
decryptedUsername
=
username
;
console
.
log
(
decryptedUsername
,
password
);
try
{
const
patientResponse
=
await
Patient
.
findOne
({
username
:
decryptedUsername
,
});
if
(
patientResponse
==
null
)
{
console
.
log
(
"
Invalid
"
);
res
.
status
(
401
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/patient/login - Invalid username
"
);
}
else
{
if
(
patientResponse
.
password
===
password
)
{
console
.
log
(
"
Success
"
);
res
.
status
(
200
).
json
({
message
:
"
Success
"
,
data
:
patientResponse
,
});
console
.
log
(
"
/patient/login - login success
"
);
}
else
{
console
.
log
(
"
Invalid
"
);
res
.
status
(
500
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/patient/login - Invalid username or password
"
);
}
}
}
catch
(
errorWhenGettingPractitionerDetails
)
{
console
.
log
(
"
Internal server error
"
);
res
.
status
(
500
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/patient/login - Internal server error
"
);
}
});
module
.
exports
=
router
;
ExpressBackend/route/practitioner-routes/login-route.js
0 → 100644
View file @
56cef06d
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
Practitioner
=
require
(
"
./../../model/practitioner/practitioner
"
);
const
DecryptWithServerKey
=
require
(
"
./../../services/decryptionservice
"
);
const
bcrypt
=
require
(
"
bcrypt
"
);
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
const
{
username
,
password
}
=
req
.
body
;
const
decryptedUsername
=
username
;
try
{
const
practitionerResponse
=
await
Practitioner
.
findOne
({
username
:
decryptedUsername
,
});
if
(
practitionerResponse
==
null
)
{
console
.
log
(
"
Invalid
"
);
res
.
status
(
401
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/practitioner/login - Invalid username
"
);
}
else
{
if
(
practitionerResponse
.
password
===
password
)
{
console
.
log
(
"
Success
"
);
res
.
status
(
200
).
json
({
message
:
"
Success
"
,
data
:
practitionerResponse
,
});
console
.
log
(
"
/practitioner/login - login success
"
);
}
else
{
console
.
log
(
"
Invalid
"
);
res
.
status
(
500
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/practitioner/login - Invalid username or password
"
);
}
}
}
catch
(
errorWhenGettingPractitionerDetails
)
{
console
.
log
(
"
Internal server error
"
);
res
.
status
(
500
).
json
({
message
:
"
Invalid
"
,
});
console
.
log
(
"
/practitioner/login - Internal server error
"
);
}
});
module
.
exports
=
router
;
ExpressBackend/server.js
View file @
56cef06d
...
...
@@ -35,6 +35,9 @@ app.use("/patient/createnft", patientNft);
const
getNFTReqs
=
require
(
"
./route/patient-routes/get-nft-requests
"
);
app
.
use
(
"
/nftrequests
"
,
getNFTReqs
);
const
patientLogin
=
require
(
"
./route/patient-routes/login-route
"
);
app
.
use
(
"
/patient/login
"
,
patientLogin
);
//practitioner routes
const
practitionerRegister
=
require
(
"
./route/practitioner-routes/registration-route
"
);
app
.
use
(
"
/practitioner/register
"
,
practitionerRegister
);
...
...
@@ -54,6 +57,9 @@ app.use("/practitioner/allpractitioner", practitionerAll);
const
practitionerUserReqs
=
require
(
"
./route/practitioner-routes/view-requests-route
"
);
app
.
use
(
"
/practitioner/practitionerrequests
"
,
practitionerUserReqs
);
const
practitionerLogin
=
require
(
"
./route/practitioner-routes/login-route
"
);
app
.
use
(
"
/practitioner/login
"
,
practitionerLogin
);
app
.
listen
(
process
.
env
.
SERVER_PORT
,
()
=>
console
.
log
(
"
Server started on port
"
+
process
.
env
.
SERVER_PORT
)
);
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