reset Pass
This commit is contained in:
parent
a866361fda
commit
0f50858c6a
10
app.js
10
app.js
|
@ -228,7 +228,7 @@ app.post('/login', async (req, res) => {
|
|||
});
|
||||
|
||||
// Logout
|
||||
app.post('/logout', (req, res) => {
|
||||
app.get('/logout', (req, res) => {
|
||||
req.session.destroy(err => {
|
||||
if (err) {
|
||||
return res.status(500).send('Internal Server Error');
|
||||
|
@ -250,17 +250,15 @@ app.post('/activate', requireAuth, requireAdmin, async (req, res) => {
|
|||
});
|
||||
|
||||
// Passwort-Zurücksetzung anfordern
|
||||
app.post('/forgot-password', async (req, res) => {
|
||||
app.post('/send-password', async (req, res) => {
|
||||
const { email } = req.body;
|
||||
console.log ( email );
|
||||
try {
|
||||
const userResult = await pool.query('SELECT * FROM users WHERE email = $1', [email]);
|
||||
if (userResult.rows.length > 0) {
|
||||
const user = userResult.rows[0];
|
||||
const token = crypto.randomBytes(20).toString('hex');
|
||||
const resetLink = `http://tkd.boergmann.it/reset-password/${token}`;
|
||||
console.log(resetLink);
|
||||
await pool.query('UPDATE users SET reset_password_token = $1, reset_password_expires = $2 WHERE id = $3', [token, Date.now() + 3600, user.id]);
|
||||
await pool.query('UPDATE users SET reset_password_token = $1, reset_password_expires = $2 WHERE id = $3', [token, selectedDate = moment().add(1,'d').toDate() , user.id]);
|
||||
|
||||
const mailOptions = {
|
||||
to: user.email,
|
||||
|
@ -287,7 +285,7 @@ app.post('/forgot-password', async (req, res) => {
|
|||
});
|
||||
|
||||
app.get('/forgot-password', async (req, res) => {
|
||||
res.render('forgot-password', {session: req.session, token : '123'})
|
||||
res.render('forgot-password', {session: req.session})
|
||||
})
|
||||
|
||||
// Passwort zurücksetzen
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<%- include('partials/header') %>
|
||||
|
||||
<h1>Forgot Password</h1>
|
||||
<form action="/forgot-password" method="post">
|
||||
<form action="/send-password" method="post">
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<a class="navbar-brand" href="/">Turnstunden WebApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
|
@ -29,12 +30,13 @@
|
|||
<% if (session && session.role === 'admin') { %>
|
||||
<li class="nav-item"><a class="nav-link" href="/admin">Admin</a></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<% if (session && session.userId) { %>
|
||||
<li><form action="/logout" method="post"><button type="submit">Logout</button></form></li>
|
||||
<li class="nav-item"><a class="nav-link" href="/logout">Logout</a></li>
|
||||
<% } else { %>
|
||||
<li class="nav-item"><a class="nav-link" href="/login">Login</a></li>
|
||||
<% } %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<h1>
|
||||
<div>
|
||||
<% if (previousTraining) { %>
|
||||
<a href="/?date=<%= moment(previousTraining.datum).format('DD.MM.YYYY') %>"> < </a>
|
||||
<a href="/?date=<%= moment(previousTraining.datum).format('DD.MM.YYYY') %>"> < </a>
|
||||
<% } %>
|
||||
Training <%= training.datum %>
|
||||
<% if (nextTraining) { %>
|
||||
|
|
Loading…
Reference in New Issue