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
3a7c5384
Commit
3a7c5384
authored
May 14, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Practitioner registration UI completed.
parent
667b5afb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
11 deletions
+178
-11
ExpressBackend/route/practitioner-routes/registration-route.js
...ssBackend/route/practitioner-routes/registration-route.js
+10
-10
emma-frontend/App.js
emma-frontend/App.js
+5
-0
emma-frontend/components/practitionerscreens/registration.js
emma-frontend/components/practitionerscreens/registration.js
+159
-0
emma-frontend/components/shared/sharedRegistration.js
emma-frontend/components/shared/sharedRegistration.js
+4
-1
No files found.
ExpressBackend/route/practitioner-routes/registration-route.js
View file @
3a7c5384
...
...
@@ -10,11 +10,11 @@ const { generateKeyPairSync } = require("crypto");
let
timestamp
;
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
//
const decryptedUserName = DecryptWithServerKey(req.body.username);
//
const password = req.body.password;
//
const decryptedEmail = DecryptWithServerKey(req.body.email);
// const decryptedWorkspace = DecryptWithServerKey(req.body.workspac
e);
// const decryptedFullName = DecryptWithServerKey(req.body.fullNam
e);
const
decryptedUserName
=
DecryptWithServerKey
(
req
.
body
.
username
);
const
password
=
req
.
body
.
password
;
const
decryptedEmail
=
DecryptWithServerKey
(
req
.
body
.
email
);
const
decryptedFullName
=
DecryptWithServerKey
(
req
.
body
.
fullNam
e
);
const
decryptedWorkspace
=
DecryptWithServerKey
(
req
.
body
.
workspac
e
);
//get the server key pair
const
serverSourceKeyPair
=
StellarSDK
.
Keypair
.
fromSecret
(
...
...
@@ -99,11 +99,11 @@ router.post("/", async (req, res) => {
);
//create the practitioner object
const
practitionerObj
=
new
Practitioner
({
username
:
req
.
body
.
usern
ame
,
password
:
req
.
body
.
password
,
email
:
req
.
body
.
e
mail
,
fullname
:
req
.
body
.
f
ullName
,
workspace
:
req
.
body
.
w
orkspace
,
username
:
decryptedUserN
ame
,
password
:
password
,
email
:
decryptedE
mail
,
fullname
:
decryptedF
ullName
,
workspace
:
decryptedW
orkspace
,
rsakey
:
b64RSApk
,
publickey
:
userKeyPair
.
publicKey
(),
timestamp
:
timestamp
,
...
...
emma-frontend/App.js
View file @
3a7c5384
...
...
@@ -18,6 +18,7 @@ import PatientConsentForm from "./components/patientscreens/consent";
import
PatientMainChatView
from
"
./components/patientscreens/patientMainChatView
"
;
import
PatientAllPractitioners
from
"
./components/patientscreens/allPractitioners
"
;
import
PatientNFTRequests
from
"
./components/patientscreens/nftRequests
"
;
import
PractitionerRegistration
from
"
./components/practitionerscreens/registration
"
;
const
Stack
=
createStackNavigator
();
...
...
@@ -111,6 +112,10 @@ export default function App() {
name
=
"
PatientNFTRequests
"
component
=
{
PatientNFTRequests
}
/
>
<
Stack
.
Screen
name
=
"
PractitionerRegistration
"
component
=
{
PractitionerRegistration
}
/
>
<
/Stack.Navigator
>
)
:
(
<
SplashScreenComponent
/>
...
...
emma-frontend/components/practitionerscreens/registration.js
0 → 100644
View file @
3a7c5384
import
{
useNavigation
}
from
"
@react-navigation/core
"
;
import
{
View
,
TextInput
,
Button
,
StyleSheet
,
Alert
}
from
"
react-native
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
EncryptWithServerKey
from
"
../../services/encryptByServerKey
"
;
import
{
LOCALBACKEND
}
from
"
../../env
"
;
import
DecryptWithServerKey
from
"
../../services/decryptByServerKey
"
;
import
AsyncStorage
from
"
@react-native-async-storage/async-storage
"
;
export
default
function
PractitionerRegistration
()
{
const
navigation
=
useNavigation
();
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
[
email
,
setEmail
]
=
useState
(
""
);
const
[
fullName
,
setFullName
]
=
useState
(
""
);
const
[
workspace
,
setWorkspace
]
=
useState
(
""
);
const
handleNext
=
async
()
=>
{
//encrypt the data
const
encryptedUsername
=
EncryptWithServerKey
(
username
);
const
encryptedPassword
=
EncryptWithServerKey
(
password
);
const
encryptedEmail
=
EncryptWithServerKey
(
email
);
const
encryptedFullName
=
EncryptWithServerKey
(
fullName
);
const
encryptedWorkplace
=
EncryptWithServerKey
(
workspace
);
//create JSON object
const
registerObject
=
{
username
:
encryptedUsername
,
password
:
encryptedPassword
,
email
:
encryptedEmail
,
fullName
:
encryptedFullName
,
workspace
:
encryptedWorkplace
,
};
const
registerUrl
=
LOCALBACKEND
+
`/practitioner/register`
;
try
{
const
regResponse
=
await
fetch
(
registerUrl
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
(
registerObject
),
});
const
responseData
=
await
regResponse
.
json
();
const
{
message
,
hash
,
pubkey
,
seed
,
rsapk
,
rsask
}
=
responseData
;
//Decrypt the data
const
decryptedStellarPublicKey
=
DecryptWithServerKey
(
pubkey
);
const
decryptedStellarSecretKey
=
DecryptWithServerKey
(
seed
);
const
decryptedRsaPublicKey
=
DecryptWithServerKey
(
rsapk
);
const
decryptedRsaSecretKey
=
DecryptWithServerKey
(
rsask
);
//save in the async storage
try
{
await
AsyncStorage
.
setItem
(
"
practitionerStellarPublicKey
"
,
decryptedStellarPublicKey
);
await
AsyncStorage
.
setItem
(
"
practitionerStellarSecretKey
"
,
decryptedStellarSecretKey
);
await
AsyncStorage
.
setItem
(
"
practitionerRsaPublicKey
"
,
decryptedRsaPublicKey
);
await
AsyncStorage
.
setItem
(
"
practitionerRsaSecretKey
"
,
decryptedRsaSecretKey
);
const
alertMessage
=
`Public key : `
+
decryptedStellarPublicKey
+
`\nSecret key : `
+
decryptedStellarSecretKey
+
`\n Save the keys in a safe place`
;
Alert
.
alert
(
"
Account keys
"
,
alertMessage
,
[
{
text
:
"
Copy
"
,
onPress
:
()
=>
{},
},
{
text
:
"
Close
"
,
style
:
"
cancel
"
,
onPress
:
()
=>
{
navigation
.
navigate
(
"
PatientMainChatView
"
);
},
},
]);
}
catch
(
errorWhenStoringInTheAsyncStorage
)
{
console
.
log
(
"
Error when saving details in the async storage :
"
,
errorWhenStoringInTheAsyncStorage
);
}
}
catch
(
errorWhenRegisteringPractitioner
)
{
console
.
log
(
"
Error when registering practitioner :
"
,
errorWhenRegisteringPractitioner
);
}
};
return
(
<
View
style
=
{
styles
.
container
}
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
User name
"
value
=
{
username
}
onChangeText
=
{(
text
)
=>
setUsername
(
text
)}
/
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
Password
"
value
=
{
password
}
onChangeText
=
{(
text
)
=>
setPassword
(
text
)}
secureTextEntry
=
{
true
}
/
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
Full Name
"
value
=
{
fullName
}
onChangeText
=
{(
text
)
=>
setFullName
(
text
)}
/
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
Workspace
"
value
=
{
workspace
}
onChangeText
=
{(
text
)
=>
setWorkspace
(
text
)}
/
>
<
TextInput
style
=
{
styles
.
input
}
placeholder
=
"
Email
"
value
=
{
email
}
onChangeText
=
{(
text
)
=>
setEmail
(
text
)}
/
>
<
Button
title
=
"
Register
"
onPress
=
{
handleNext
}
/
>
<
/View
>
);
}
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
alignItems
:
"
center
"
,
justifyContent
:
"
center
"
,
},
input
:
{
width
:
"
80%
"
,
height
:
40
,
marginVertical
:
10
,
paddingHorizontal
:
10
,
borderColor
:
"
gray
"
,
borderWidth
:
1
,
borderRadius
:
5
,
},
});
emma-frontend/components/shared/sharedRegistration.js
View file @
3a7c5384
...
...
@@ -15,7 +15,10 @@ export default function SharedRegisterScreen({ navigation }) {
<
View
style
=
{
styles
.
separator
}
/
>
<
Button
title
=
"
Practitioner Register
"
onPress
=
{()
=>
console
.
log
(
"
Practitioner Register
"
)}
onPress
=
{()
=>
{
console
.
log
(
"
PractitionerRegistration
"
);
navigation
.
navigate
(
"
PractitionerRegistration
"
);
}}
/
>
<
/View
>
<
/View
>
...
...
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