Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
0f5f6b65
Commit
0f5f6b65
authored
Aug 22, 2023
by
janithGamage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc :update project
parent
20cb9f30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
Project/Backend/Server_Node/controllers/user.controller.js
Project/Backend/Server_Node/controllers/user.controller.js
+6
-2
Project/Backend/Server_Node/models/user.model.js
Project/Backend/Server_Node/models/user.model.js
+1
-2
Project/Frontend/SignConnectPlus/src/contexts/JWTContext.tsx
Project/Frontend/SignConnectPlus/src/contexts/JWTContext.tsx
+22
-11
No files found.
Project/Backend/Server_Node/controllers/user.controller.js
View file @
0f5f6b65
...
@@ -43,8 +43,12 @@ export const signUp = async (req, res) => {
...
@@ -43,8 +43,12 @@ export const signUp = async (req, res) => {
if
(
lastName
===
null
||
typeof
lastName
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Last Name Field Required
"
})
if
(
lastName
===
null
||
typeof
lastName
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Last Name Field Required
"
})
if
(
contactNumber
===
null
||
typeof
contactNumber
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Contact Number Field Required
"
})
if
(
contactNumber
===
null
||
typeof
contactNumber
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Contact Number Field Required
"
})
const
existingUser
=
await
User
.
findOne
({
email
:
email
})
const
existingUserByEmail
=
await
User
.
findOne
({
email
:
email
})
if
(
existingUser
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
User already exist
"
})
if
(
existingUserByEmail
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
User already exist
"
})
const
existingUserByContactNo
=
await
User
.
findOne
({
contactNumber
:
contactNumber
})
if
(
existingUserByContactNo
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
User already exist
"
})
if
(
password
===
null
||
typeof
password
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Password Field Required
"
})
if
(
password
===
null
||
typeof
password
==
"
undefined
"
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Password Field Required
"
})
if
(
password
!==
confirmPassword
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Password doesn't match
"
})
if
(
password
!==
confirmPassword
)
return
res
.
status
(
400
).
json
({
code
:
"
02
"
,
message
:
"
Password doesn't match
"
})
...
...
Project/Backend/Server_Node/models/user.model.js
View file @
0f5f6b65
...
@@ -16,8 +16,7 @@ const userSchema = mongoose.Schema({
...
@@ -16,8 +16,7 @@ const userSchema = mongoose.Schema({
},
},
contactNumber
:
{
contactNumber
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
unique
:
true
},
},
password
:
{
password
:
{
type
:
String
,
type
:
String
,
...
...
Project/Frontend/SignConnectPlus/src/contexts/JWTContext.tsx
View file @
0f5f6b65
...
@@ -125,9 +125,8 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => {
...
@@ -125,9 +125,8 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => {
};
};
const
registerUser
=
async
(
email
:
string
,
password
:
string
,
firstName
:
string
,
lastName
:
string
,
contactNumber
:
string
,
confirmPassword
:
string
)
=>
{
const
registerUser
=
async
(
email
:
string
,
password
:
string
,
firstName
:
string
,
lastName
:
string
,
contactNumber
:
string
,
confirmPassword
:
string
)
=>
{
// todo: this flow need to be recode as it not verified
const
id
=
chance
.
bb_pin
();
const
response
=
await
axiosServices
.
post
(
'
/rest_node/user/sign-up
'
,
{
const
response
=
await
axiosServices
.
post
(
'
/rest_node/user/sign-up
'
,
{
firstName
,
firstName
,
lastName
,
lastName
,
email
,
email
,
...
@@ -135,24 +134,36 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => {
...
@@ -135,24 +134,36 @@ export const JWTProvider = ({ children }: { children: React.ReactElement }) => {
password
,
password
,
confirmPassword
,
confirmPassword
,
type
:
"
member
"
type
:
"
member
"
});
});
let
users
=
response
.
data
;
const
user
=
response
.
data
.
result
;
if
(
window
.
localStorage
.
getItem
(
'
users
'
)
!==
undefined
&&
window
.
localStorage
.
getItem
(
'
users
'
)
!==
null
)
{
if
(
window
.
localStorage
.
getItem
(
'
users
'
)
!==
undefined
&&
window
.
localStorage
.
getItem
(
'
users
'
)
!==
null
)
{
const
localUsers
=
window
.
localStorage
.
getItem
(
'
users
'
);
const
localUsers
=
window
.
localStorage
.
getItem
(
'
users
'
);
users
=
[
const
users
=
[
...
JSON
.
parse
(
localUsers
!
),
...
JSON
.
parse
(
localUsers
!
),
{
{
id
,
id
:
user
.
_id
,
email
,
email
:
user
.
email
,
password
,
password
:
user
.
password
,
name
:
`
${
firstName
}
${
lastName
}
`
name
:
`
${
user
.
firstName
}
${
user
.
lastName
}
`
}
}
];
];
window
.
localStorage
.
setItem
(
'
users
'
,
JSON
.
stringify
(
users
));
}
else
{
const
users
=
[
{
id
:
user
.
_id
,
email
:
user
.
email
,
password
:
user
.
password
,
name
:
`
${
user
.
firstName
}
${
user
.
lastName
}
`
}
];
window
.
localStorage
.
setItem
(
'
users
'
,
JSON
.
stringify
(
users
));
}
}
window
.
localStorage
.
setItem
(
'
users
'
,
JSON
.
stringify
(
users
));
};
};
const
logout
=
()
=>
{
const
logout
=
()
=>
{
setSession
(
null
);
setSession
(
null
);
dispatch
({
type
:
LOGOUT
});
dispatch
({
type
:
LOGOUT
});
...
...
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