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
62796b44
Commit
62796b44
authored
May 17, 2023
by
Ishini Kiridena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login routes and login called on the FE
parent
56cef06d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
137 additions
and
20 deletions
+137
-20
ExpressBackend/route/patient-routes/login-route.js
ExpressBackend/route/patient-routes/login-route.js
+1
-1
ExpressBackend/route/practitioner-routes/login-route.js
ExpressBackend/route/practitioner-routes/login-route.js
+1
-1
emma-frontend/App.js
emma-frontend/App.js
+7
-0
emma-frontend/components/patientscreens/registration/login.js
...-frontend/components/patientscreens/registration/login.js
+55
-0
emma-frontend/components/practitionerscreens/login.js
emma-frontend/components/practitionerscreens/login.js
+55
-0
emma-frontend/components/shared/sharedLogin.js
emma-frontend/components/shared/sharedLogin.js
+2
-2
emma-frontend/package-lock.json
emma-frontend/package-lock.json
+15
-15
emma-frontend/package.json
emma-frontend/package.json
+1
-1
No files found.
ExpressBackend/route/patient-routes/login-route.js
View file @
62796b44
...
...
@@ -8,7 +8,7 @@ router.post("/", async (req, res) => {
const
username
=
req
.
body
.
username
;
const
password
=
req
.
body
.
password
;
const
decryptedUsername
=
username
;
const
decryptedUsername
=
DecryptWithServerKey
(
username
)
;
console
.
log
(
decryptedUsername
,
password
);
...
...
ExpressBackend/route/practitioner-routes/login-route.js
View file @
62796b44
...
...
@@ -7,7 +7,7 @@ const bcrypt = require("bcrypt");
router
.
post
(
"
/
"
,
async
(
req
,
res
)
=>
{
const
{
username
,
password
}
=
req
.
body
;
const
decryptedUsername
=
username
;
const
decryptedUsername
=
DecryptWithServerKey
(
username
)
;
try
{
const
practitionerResponse
=
await
Practitioner
.
findOne
({
...
...
emma-frontend/App.js
View file @
62796b44
...
...
@@ -21,6 +21,8 @@ import PatientNFTRequests from "./components/patientscreens/nftRequests";
import
PractitionerRegistration
from
"
./components/practitionerscreens/registration
"
;
import
PractitionerMainView
from
"
./components/practitionerscreens/mainViewWithMenu
"
;
import
PatientRequests
from
"
./components/practitionerscreens/patientRequestsView
"
;
import
PatientLogin
from
"
./components/patientscreens/registration/login
"
;
import
PractitionerLogin
from
"
./components/practitionerscreens/login
"
;
const
Stack
=
createStackNavigator
();
...
...
@@ -122,7 +124,12 @@ export default function App() {
name
=
"
PractitionerMainView
"
component
=
{
PractitionerMainView
}
/
>
<
Stack
.
Screen
name
=
"
PatientLogin
"
component
=
{
PatientLogin
}
/
>
<
Stack
.
Screen
name
=
"
PatientRequests
"
component
=
{
PatientRequests
}
/
>
<
Stack
.
Screen
name
=
"
PractitionerLogin
"
component
=
{
PractitionerLogin
}
/
>
<
/Stack.Navigator
>
)
:
(
<
SplashScreenComponent
/>
...
...
emma-frontend/components/patientscreens/registration/login.js
0 → 100644
View file @
62796b44
import
React
,
{
useState
}
from
"
react
"
;
import
{
View
,
TextInput
,
Button
,
Alert
}
from
"
react-native
"
;
import
{
LOCALBACKEND
}
from
"
../../../env
"
;
import
EncryptWithServerKey
from
"
../../../services/encryptByServerKey
"
;
export
default
function
PatientLogin
({
navigation
,
route
})
{
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
handleLogin
=
async
()
=>
{
const
encryptedUsername
=
EncryptWithServerKey
(
username
);
const
encryptedPassword
=
EncryptWithServerKey
(
password
);
try
{
const
loginUrl
=
LOCALBACKEND
+
`/patient/login`
;
const
response
=
await
fetch
(
loginUrl
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
username
:
encryptedUsername
,
password
:
encryptedPassword
,
}),
});
if
(
response
.
ok
)
{
navigation
.
navigate
(
"
PatientMainChatView
"
);
}
else
{
// Login failed, show an error message
Alert
.
alert
(
"
Login Failed
"
,
"
Invalid username or password
"
);
}
}
catch
(
error
)
{
console
.
error
(
error
);
// Handle any network or server errors
Alert
.
alert
(
"
Error
"
,
"
An error occurred while logging in
"
);
}
};
return
(
<
View
>
<
TextInput
placeholder
=
"
Username
"
value
=
{
username
}
onChangeText
=
{
setUsername
}
/
>
<
TextInput
placeholder
=
"
Password
"
value
=
{
password
}
onChangeText
=
{
setPassword
}
secureTextEntry
/>
<
Button
title
=
"
Login
"
onPress
=
{
handleLogin
}
/
>
<
/View
>
);
}
emma-frontend/components/practitionerscreens/login.js
0 → 100644
View file @
62796b44
import
React
,
{
useState
}
from
"
react
"
;
import
{
View
,
TextInput
,
Button
,
Alert
}
from
"
react-native
"
;
import
{
LOCALBACKEND
}
from
"
../../env
"
;
import
EncryptWithServerKey
from
"
../../services/encryptByServerKey
"
;
export
default
function
PractitionerLogin
({
navigation
,
route
})
{
const
[
username
,
setUsername
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
handleLogin
=
async
()
=>
{
const
encryptedUsername
=
EncryptWithServerKey
(
username
);
const
encryptedPassword
=
EncryptWithServerKey
(
password
);
try
{
const
loginUrl
=
LOCALBACKEND
+
"
/practitioner/login
"
;
const
response
=
await
fetch
(
loginUrl
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
username
:
encryptedUsername
,
password
:
encryptedPassword
,
}),
});
if
(
response
.
ok
)
{
navigation
.
navigate
(
"
PractitionerMainView
"
);
}
else
{
// Login failed, show an error message
Alert
.
alert
(
"
Login Failed
"
,
"
Invalid username or password
"
);
}
}
catch
(
error
)
{
console
.
error
(
error
);
// Handle any network or server errors
Alert
.
alert
(
"
Error
"
,
"
An error occurred while logging in
"
);
}
};
return
(
<
View
>
<
TextInput
placeholder
=
"
Username
"
value
=
{
username
}
onChangeText
=
{
setUsername
}
/
>
<
TextInput
placeholder
=
"
Password
"
value
=
{
password
}
onChangeText
=
{
setPassword
}
secureTextEntry
/>
<
Button
title
=
"
Login
"
onPress
=
{
handleLogin
}
/
>
<
/View
>
);
}
emma-frontend/components/shared/sharedLogin.js
View file @
62796b44
...
...
@@ -7,12 +7,12 @@ export default function SharedLogin({ navigation }) {
<
View
style
=
{
styles
.
buttonContainer
}
>
<
Button
title
=
"
I am here to get help
"
onPress
=
{()
=>
console
.
log
(
"
Patient l
ogin
"
)}
onPress
=
{()
=>
navigation
.
navigate
(
"
PatientL
ogin
"
)}
/
>
<
View
style
=
{
styles
.
separator
}
/
>
<
Button
title
=
"
I am here to help
"
onPress
=
{()
=>
console
.
log
(
"
Practitioner l
ogin
"
)}
onPress
=
{()
=>
navigation
.
navigate
(
"
PractitionerL
ogin
"
)}
/
>
<
/View
>
<
/View
>
...
...
emma-frontend/package-lock.json
View file @
62796b44
...
...
@@ -17,7 +17,7 @@
"expo"
:
"~48.0.15"
,
"expo-status-bar"
:
"~1.4.4"
,
"react"
:
"18.2.0"
,
"react-native"
:
"0.71.
7
"
,
"react-native"
:
"0.71.
8
"
,
"react-native-crypto-js"
:
"^1.0.0"
,
"react-native-datepicker"
:
"^1.7.2"
,
"react-native-simple-radio-button"
:
"^2.7.4"
,
...
...
@@ -11240,9 +11240,9 @@
"integrity"
:
"sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"node_modules/react-native"
:
{
"version"
:
"0.71.
7
"
,
"resolved"
:
"https://registry.npmjs.org/react-native/-/react-native-0.71.
7
.tgz"
,
"integrity"
:
"sha512-
Id6iRLS581fJMFGbBl1jP5uSmjExtGOvw5Gvh7694zISXjsRAsFMmU+izs0pyCLqDBoHK7y4BT7WGPGw693nYw
=="
,
"version"
:
"0.71.
8
"
,
"resolved"
:
"https://registry.npmjs.org/react-native/-/react-native-0.71.
8
.tgz"
,
"integrity"
:
"sha512-
ftMAuhpgTkbHU9brrqsEyxcNrpYvXKeATY+if22Nfhhg1zW+6wn95w9otwTnA3xHkljPCbng8mUhmmERjGEl7g
=="
,
"dependencies"
:
{
"@jest/create-cache-key-function"
:
"^29.2.1"
,
"@react-native-community/cli"
:
"10.2.2"
,
...
...
@@ -11269,7 +11269,7 @@
"promise"
:
"^8.3.0"
,
"react-devtools-core"
:
"^4.26.1"
,
"react-native-codegen"
:
"^0.71.5"
,
"react-native-gradle-plugin"
:
"^0.71.1
7
"
,
"react-native-gradle-plugin"
:
"^0.71.1
8
"
,
"react-refresh"
:
"^0.4.0"
,
"react-shallow-renderer"
:
"^16.15.0"
,
"regenerator-runtime"
:
"^0.13.2"
,
...
...
@@ -11331,9 +11331,9 @@
}
},
"node_modules/react-native-gradle-plugin"
:
{
"version"
:
"0.71.1
7
"
,
"resolved"
:
"https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.1
7
.tgz"
,
"integrity"
:
"sha512-
OXXYgpISEqERwjSlaCiaQY6cTY5CH6j73gdkWpK0hedxtiWMWgH+i5TOi4hIGYitm9kQBeyDu+wim9fA8ROFJA
=="
"version"
:
"0.71.1
8
"
,
"resolved"
:
"https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.1
8
.tgz"
,
"integrity"
:
"sha512-
7F6bD7B8Xsn3JllxcwHhFcsl9aHIig47+3eN4IHFNqfLhZr++3ElDrcqfMzugM+niWbaMi7bJ0kAkAL8eCpdWg
=="
},
"node_modules/react-native-reanimated"
:
{
"version"
:
"3.1.0"
,
...
...
@@ -21980,9 +21980,9 @@
"integrity"
:
"sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"react-native"
:
{
"version"
:
"0.71.
7
"
,
"resolved"
:
"https://registry.npmjs.org/react-native/-/react-native-0.71.
7
.tgz"
,
"integrity"
:
"sha512-
Id6iRLS581fJMFGbBl1jP5uSmjExtGOvw5Gvh7694zISXjsRAsFMmU+izs0pyCLqDBoHK7y4BT7WGPGw693nYw
=="
,
"version"
:
"0.71.
8
"
,
"resolved"
:
"https://registry.npmjs.org/react-native/-/react-native-0.71.
8
.tgz"
,
"integrity"
:
"sha512-
ftMAuhpgTkbHU9brrqsEyxcNrpYvXKeATY+if22Nfhhg1zW+6wn95w9otwTnA3xHkljPCbng8mUhmmERjGEl7g
=="
,
"requires"
:
{
"@jest/create-cache-key-function"
:
"^29.2.1"
,
"@react-native-community/cli"
:
"10.2.2"
,
...
...
@@ -22009,7 +22009,7 @@
"promise"
:
"^8.3.0"
,
"react-devtools-core"
:
"^4.26.1"
,
"react-native-codegen"
:
"^0.71.5"
,
"react-native-gradle-plugin"
:
"^0.71.1
7
"
,
"react-native-gradle-plugin"
:
"^0.71.1
8
"
,
"react-refresh"
:
"^0.4.0"
,
"react-shallow-renderer"
:
"^16.15.0"
,
"regenerator-runtime"
:
"^0.13.2"
,
...
...
@@ -22076,9 +22076,9 @@
}
},
"react-native-gradle-plugin"
:
{
"version"
:
"0.71.1
7
"
,
"resolved"
:
"https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.1
7
.tgz"
,
"integrity"
:
"sha512-
OXXYgpISEqERwjSlaCiaQY6cTY5CH6j73gdkWpK0hedxtiWMWgH+i5TOi4hIGYitm9kQBeyDu+wim9fA8ROFJA
=="
"version"
:
"0.71.1
8
"
,
"resolved"
:
"https://registry.npmjs.org/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.1
8
.tgz"
,
"integrity"
:
"sha512-
7F6bD7B8Xsn3JllxcwHhFcsl9aHIig47+3eN4IHFNqfLhZr++3ElDrcqfMzugM+niWbaMi7bJ0kAkAL8eCpdWg
=="
},
"react-native-reanimated"
:
{
"version"
:
"3.1.0"
,
...
...
emma-frontend/package.json
View file @
62796b44
...
...
@@ -18,7 +18,7 @@
"expo"
:
"~48.0.15"
,
"expo-status-bar"
:
"~1.4.4"
,
"react"
:
"18.2.0"
,
"react-native"
:
"0.71.
7
"
,
"react-native"
:
"0.71.
8
"
,
"react-native-crypto-js"
:
"^1.0.0"
,
"react-native-datepicker"
:
"^1.7.2"
,
"react-native-simple-radio-button"
:
"^2.7.4"
,
...
...
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