Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PB138 - Project - Restaurant Corona
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andrej Bátora
PB138 - Project - Restaurant Corona
Commits
036f1d88
There was an error fetching the commit references. Please try again later.
Commit
036f1d88
authored
2 years ago
by
undefined
Browse files
Options
Downloads
Patches
Plain Diff
fix add staff endpoint
parent
2a1cc3af
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/src/controllers/staff.controllers.ts
+24
-1
24 additions, 1 deletion
api/src/controllers/staff.controllers.ts
api/src/middleware/staff.middleware.ts
+2
-1
2 additions, 1 deletion
api/src/middleware/staff.middleware.ts
with
26 additions
and
2 deletions
api/src/controllers/staff.controllers.ts
+
24
−
1
View file @
036f1d88
...
...
@@ -28,7 +28,30 @@ export const login = async (req: Request, res: Response) => {
};
export
const
addAccount
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
{
username
,
password
}
=
req
.
body
;
const
{
username
,
password
}
=
req
.
query
;
if
(
typeof
username
!==
"
string
"
)
{
//TODO: toto má byť asi niekde inde (dalsich 20 riadkov)
return
res
.
status
(
400
).
json
({
message
:
"
Query param 'username' has to be of type string
"
});
}
if
(
typeof
password
!==
"
string
"
)
{
return
res
.
status
(
400
).
json
({
message
:
"
Query param 'password' has to be of type string
"
});
}
const
staff
=
await
prisma
.
staff
.
findUnique
({
where
:{
username
,
}
})
if
(
staff
){
return
res
.
status
(
400
).
json
({
status
:
'
error
'
,
message
:
'
username already exists
'
});
}
bcrypt
.
hash
(
password
,
10
,
async
(
err
:
any
,
hash
:
any
)
=>
{
if
(
err
){
...
...
This diff is collapsed.
Click to expand it.
api/src/middleware/staff.middleware.ts
+
2
−
1
View file @
036f1d88
...
...
@@ -26,7 +26,8 @@ export const authorizeStaff = (req: Request, res: Response, next: NextFunction)
};
export
const
validateStaffLogin
=
async
(
req
:
Request
,
res
:
Response
,
next
:
NextFunction
)
=>
{
const
{
username
,
password
}
=
req
.
body
;
const
{
username
,
password
}
=
req
.
query
;
if
(
!
username
||
!
password
){
return
res
.
status
(
400
).
json
({
status
:
'
error
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment