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
6771b6f6
Commit
6771b6f6
authored
Jan 16, 2023
by
Kiridena I.T.K_IT19981840
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'update-the-patient-genesis' into 'master'
Changes added to the genesis of patient See merge request
!14
parents
eab73446
b49cd585
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
37 deletions
+146
-37
ExpressBackend/route/patient-routes/emotion-route.js
ExpressBackend/route/patient-routes/emotion-route.js
+2
-1
ExpressBackend/route/patient-routes/mental-state-router.js
ExpressBackend/route/patient-routes/mental-state-router.js
+2
-1
ExpressBackend/route/patient-routes/register-route.js
ExpressBackend/route/patient-routes/register-route.js
+142
-35
No files found.
ExpressBackend/route/patient-routes/emotion-route.js
View file @
6771b6f6
...
...
@@ -4,6 +4,7 @@ const DecryptWithServerKey = require("./../../services/decryptionservice");
const
UserSchema
=
require
(
"
../../model/patient/patient
"
);
const
StellarSDK
=
require
(
"
stellar-sdk
"
);
const
PatientTransaction
=
require
(
"
../../model/stellar/transactionDetails
"
);
const
EncryptionService
=
require
(
"
./../../services/encryptionservice
"
);
//Add user emotions to blockchain and transaction details to database
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
...
...
@@ -52,7 +53,7 @@ router.post("/", async (req, res) => {
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Emotion
"
,
value
:
emotion
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
emotion
,
userSeed
)
,
})
)
.
addOperation
(
...
...
ExpressBackend/route/patient-routes/mental-state-router.js
View file @
6771b6f6
...
...
@@ -4,6 +4,7 @@ const DecryptWithServerKey = require("./../../services/decryptionservice");
const
UserSchema
=
require
(
"
../../model/patient/patient
"
);
const
StellarSDK
=
require
(
"
stellar-sdk
"
);
const
PatientTransaction
=
require
(
"
../../model/stellar/transactionDetails
"
);
const
EncryptionService
=
require
(
"
./../../services/encryptionservice
"
);
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
// const userPubKey = DecryptWithServerKey(req.body.pubkey);
...
...
@@ -52,7 +53,7 @@ router.post("/", async (req, res) => {
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Mental state
"
,
value
:
state
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
state
,
userSeed
)
,
})
)
.
addOperation
(
...
...
ExpressBackend/route/patient-routes/register-route.js
View file @
6771b6f6
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
RegisterRequestSchema
=
require
(
"
./../../model/patient/registration
"
);
require
(
"
dotenv
"
).
config
();
const
StellarSDK
=
require
(
"
stellar-sdk
"
);
const
DecryptWithServerKey
=
require
(
"
./../../services/decryptionservice
"
);
...
...
@@ -12,18 +11,23 @@ let timestamp;
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
//decrypt user request details
//! @todo do not decrypt the password
const
decryptedEmail
=
DecryptWithServerKey
(
req
.
body
.
email
);
const
decryptedPassword
=
DecryptWithServerKey
(
req
.
body
.
password
);
const
decryptedUserName
=
DecryptWithServerKey
(
req
.
body
.
email
);
//catching the request
const
request
=
new
RegisterRequestSchema
({
email
:
req
.
body
.
email
,
username
:
req
.
body
.
username
,
password
:
req
.
body
.
password
,
});
console
.
log
(
request
);
const
decryptedEmail
=
req
.
body
.
email
;
const
decryptedPassword
=
req
.
body
.
password
;
const
decryptedUserName
=
req
.
body
.
username
;
const
decryptedName
=
req
.
body
.
name
;
const
decryptedPronoun
=
req
.
body
.
pronoun
;
const
decryptedBirthday
=
req
.
body
.
birthday
;
const
decryptedGender
=
req
.
body
.
gender
;
const
decryptedOrphan
=
req
.
body
.
orphan
;
const
decryptedSiblingCount
=
req
.
body
.
siblingcount
;
const
decryptedRelationship
=
req
.
body
.
relationship
;
const
decryptedChildCount
=
req
.
body
.
childcount
;
const
decryptedSexualPreference
=
req
.
body
.
sexualpreference
;
const
decryptedReligion
=
req
.
body
.
religion
;
const
decryptedEthnicity
=
req
.
body
.
ethnicity
;
const
decryptedNationality
=
req
.
body
.
nationality
;
const
decryptedEducationLevel
=
req
.
body
.
educationlevel
;
const
decryptedEmployed
=
req
.
body
.
employed
;
//get the server key pair
const
serverSourceKeyPair
=
StellarSDK
.
Keypair
.
fromSecret
(
...
...
@@ -48,7 +52,7 @@ router.post("/", async (req, res) => {
.
addOperation
(
StellarSDK
.
Operation
.
createAccount
({
destination
:
userKeyPair
.
publicKey
(),
startingBalance
:
"
10
"
,
startingBalance
:
"
10
0
"
,
})
)
.
setTimeout
(
30
)
...
...
@@ -83,20 +87,6 @@ router.post("/", async (req, res) => {
"
Account creation details saved in the database
"
+
saveInCollection
);
//encrypt user entered details with stellar seed
const
encEmail
=
EncryptionService
.
EncryptWithStellarSeed
(
request
.
email
,
userKeyPair
.
secret
()
);
const
encUsername
=
EncryptionService
.
EncryptWithStellarSeed
(
request
.
username
,
userKeyPair
.
secret
()
);
const
encPassword
=
EncryptionService
.
EncryptWithStellarSeed
(
request
.
password
,
userKeyPair
.
secret
()
);
//get the user keypair
const
userSourceKeyPair
=
StellarSDK
.
Keypair
.
fromSecret
(
userKeyPair
.
secret
()
...
...
@@ -118,19 +108,136 @@ router.post("/", async (req, res) => {
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Email Address
"
,
value
:
encEmail
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedEmail
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Username
"
,
value
:
encUsername
,
name
:
"
Name
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedName
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Pronouns
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedPronoun
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Birthday
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedBirthday
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Gender
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedGender
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Orphan
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedOrphan
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Sibling Count
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedSiblingCount
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Previous
"
,
value
:
""
,
name
:
"
Relationship Status
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedRelationship
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Child Count
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedChildCount
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Sexual Preference
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedSexualPreference
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Religion
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedReligion
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Ethnicity
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedEthnicity
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Nationality
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedNationality
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Education level
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedEducationLevel
,
userKeyPair
.
secret
()
),
})
)
.
addOperation
(
StellarSDK
.
Operation
.
manageData
({
name
:
"
Employed
"
,
value
:
EncryptionService
.
EncryptWithStellarSeed
(
decryptedEmployed
,
userKeyPair
.
secret
()
),
})
)
.
setTimeout
(
30
)
...
...
@@ -156,9 +263,9 @@ router.post("/", async (req, res) => {
console
.
log
(
new
Date
());
//create the user collection object to be added to the DB
const
userCollectionObject
=
new
UserSchema
({
username
:
req
.
body
.
usern
ame
,
username
:
decryptedUserN
ame
,
password
:
req
.
body
.
password
,
email
:
req
.
body
.
e
mail
,
email
:
decryptedE
mail
,
publickey
:
userKeyPair
.
publicKey
(),
genesishash
:
genesisTxnResult
.
hash
,
currenthash
:
genesisTxnResult
.
hash
,
...
...
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