Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IP1_Gruppe8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
Sophia Haupt
IP1_Gruppe8
Commits
cdcf762f
Commit
cdcf762f
authored
1 month ago
by
Lilith Faust
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
155b3732
a7b76c99
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
userman_all/server/src/server.ts
+9
-8
9 additions, 8 deletions
userman_all/server/src/server.ts
with
9 additions
and
8 deletions
userman_all/server/src/server.ts
+
9
−
8
View file @
cdcf762f
...
@@ -305,7 +305,7 @@ app.post('/logout', isLoggedIn, (req: Request, res: Response): void => {
...
@@ -305,7 +305,7 @@ app.post('/logout', isLoggedIn, (req: Request, res: Response): void => {
//Benutzer registrieren (POST /user)
//Benutzer registrieren (POST /user)
app
.
post
(
'
/user
'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
void
>
=>
{
app
.
post
(
'
/user
'
,
async
(
req
:
Request
,
res
:
Response
):
Promise
<
void
>
=>
{
const
firstName
:
string
=
req
.
body
.
firstName
;
const
firstName
:
string
=
req
.
body
.
firstName
;
//Variable firstName wird erstellt, mit req.body kann man auf Nutzdaten zugreifen, in dem Falle auf first name
const
lastName
:
string
=
req
.
body
.
lastName
;
const
lastName
:
string
=
req
.
body
.
lastName
;
const
eMail
:
string
=
req
.
body
.
eMail
;
const
eMail
:
string
=
req
.
body
.
eMail
;
const
password
:
string
=
req
.
body
.
password
;
const
password
:
string
=
req
.
body
.
password
;
...
@@ -326,23 +326,24 @@ app.post('/user', async (req: Request, res: Response): Promise<void> => {
...
@@ -326,23 +326,24 @@ app.post('/user', async (req: Request, res: Response): Promise<void> => {
});
});
return
;
return
;
}
}
//aufrufen der namen, email, passwort
const
data
:
[
string
,
string
,
string
,
string
]
=
[
const
data
:
[
string
,
string
,
string
,
string
]
=
[
eMail
,
crypto
.
createHash
(
"
sha512
"
).
update
(
password
).
digest
(
'
hex
'
),
firstName
,
firstName
,
lastName
,
lastName
,
];
eMail
,
crypto
.
createHash
(
"
sha512
"
).
update
(
password
).
digest
(
'
hex
'
)
const
query
:
string
=
'
INSERT INTO user (eMail, password, firstName, lastName) VALUES (?, ?, ?, ?);
'
;
];
//soll in user Tabelle eingepflegt werden
const
query
:
string
=
'
INSERT INTO user (firstName, lastName, eMail, password) VALUES (?, ?, ?, ?);
'
;
try
{
try
{
const
[
result
]
=
await
database
.
query
<
ResultSetHeader
>
(
query
,
data
);
const
[
result
]
=
await
database
.
query
<
ResultSetHeader
>
(
query
,
data
);
//daten werden von dem neu registrierten Nutzer gespeichert
// Hol den neu erstellten Benutzer aus der Datenbank
// Hol den neu erstellten Benutzer aus der Datenbank
const
[
userRows
]
=
await
database
.
query
<
RowDataPacket
[]
>
(
const
[
userRows
]
=
await
database
.
query
<
RowDataPacket
[]
>
(
'
SELECT * FROM user WHERE user_id = ?;
'
,
'
SELECT * FROM user WHERE user_id = ?;
'
,
[
result
.
insertId
]
[
result
.
insertId
]
//=vom registrierten User id nehmen
);
);
if
(
userRows
.
length
===
1
)
{
if
(
userRows
.
length
===
1
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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