Skip to content
Snippets Groups Projects
Commit cdcf762f authored by Lilith Faust's avatar Lilith Faust
Browse files

Merge remote-tracking branch 'origin/master'

parents 155b3732 a7b76c99
No related merge requests found
......@@ -305,7 +305,7 @@ app.post('/logout', isLoggedIn, (req: Request, res: Response): void => {
//Benutzer registrieren (POST /user)
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 eMail: string = req.body.eMail;
const password: string = req.body.password;
......@@ -326,23 +326,24 @@ app.post('/user', async (req: Request, res: Response): Promise<void> => {
});
return;
}
//aufrufen der namen, email, passwort
const data: [string, string, string, string] = [
eMail,
crypto.createHash("sha512").update(password).digest('hex'),
firstName,
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 {
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
const [userRows] = await database.query<RowDataPacket[]>(
'SELECT * FROM user WHERE user_id = ?;',
[result.insertId]
[result.insertId] //=vom registrierten User id nehmen
);
if (userRows.length === 1) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment