Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fahrtenbuch
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
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
SWP WS21_22 - Fahrtenbuch
Team Einhorn
fahrtenbuch
Commits
5a7f24b3
Commit
5a7f24b3
authored
3 years ago
by
elit04
Browse files
Options
Downloads
Patches
Plain Diff
create log entry controller
parent
df23fd02
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/src/controllers/auth.controllers.ts
+51
-1
51 additions, 1 deletion
server/src/controllers/auth.controllers.ts
with
51 additions
and
1 deletion
server/src/controllers/auth.controllers.ts
+
51
−
1
View file @
5a7f24b3
...
@@ -2,8 +2,11 @@ import bcrypt from "bcrypt";
...
@@ -2,8 +2,11 @@ import bcrypt from "bcrypt";
import
{
Request
,
Response
}
from
"
express
"
;
import
{
Request
,
Response
}
from
"
express
"
;
import
jwt
from
"
jsonwebtoken
"
;
import
jwt
from
"
jsonwebtoken
"
;
import
Employee
from
"
../db/models/Employee
"
;
import
Employee
from
"
../db/models/Employee
"
;
import
CheckIn
from
"
../db/models/CheckIn
"
;
import
Boat
from
"
../db/models/Boat
"
;
import
envVars
from
"
../config
"
;
import
envVars
from
"
../config
"
;
//log in
const
authLoginController
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
const
authLoginController
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
try
{
const
{
email
,
password
}
=
req
.
body
;
const
{
email
,
password
}
=
req
.
body
;
...
@@ -38,4 +41,51 @@ const authLoginController = async (req: Request, res: Response) => {
...
@@ -38,4 +41,51 @@ const authLoginController = async (req: Request, res: Response) => {
return
res
.
status
(
500
).
json
({
success
:
false
,
error
:
"
serverError
"
});
return
res
.
status
(
500
).
json
({
success
:
false
,
error
:
"
serverError
"
});
}
}
};
};
export
default
authLoginController
;
//create log entry
const
createLogEntry
=
async
(
req
:
Request
,
res
:
Response
)
=>
{
try
{
const
logEntry
=
req
.
body
;
const
boatid
=
Boat
.
findByPk
(
logEntry
.
boatID
);
//get status of boat
const
bootAvailability
=
(
await
boatid
).
status
;
//if boat is not available => it's locked
if
(
!
(
bootAvailability
===
true
))
{
return
res
.
status
(
409
).
json
({
success
:
false
,
error
:
"
BoatLocked
"
});
};
const
newLogEntry
=
await
CheckIn
.
create
(
logEntry
);
return
res
.
status
(
201
).
json
({
success
:
true
,
account
:
{
startTime
:
newLogEntry
.
startTime
,
estimatedEndTime
:
newLogEntry
.
estimatedEndTime
,
email
:
newLogEntry
.
email
,
firstName
:
newLogEntry
.
firstName
,
lastName
:
newLogEntry
.
lastName
,
additionalClients
:
newLogEntry
.
additionalClients
,
boatID
:
newLogEntry
.
boatID
,
},
});
}
catch
(
error
)
{
console
.
error
(
error
.
message
);
return
res
.
status
(
500
).
json
({
success
:
false
,
error
:
"
serverError
"
});
}
};
const
authControllers
=
{
authLoginController
,
createLogEntry
,
};
export
default
authControllers
;
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