tethys.backend/app/Controllers/Http/Auth/AuthController.ts
Arno Kaimbacher b2dce0259a - npm updates
- Admins can no longer delete any users or roles
- Additionally, the name of a role in edit mode is now read-only
- extra new SetupConfirmation.vue compoenent for verifying qrcode 2FA
- adapted ci.yaml
2024-02-14 13:47:10 +01:00

51 lines
1.9 KiB
TypeScript

import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
// import User from 'App/Models/User';
// import Hash from '@ioc:Adonis/Core/Hash';
// import InvalidCredentialException from 'App/Exceptions/InvalidCredentialException';
import AuthValidator from 'App/Validators/AuthValidator';
export default class AuthController {
// login function
public async login({ request, response, auth, session }: HttpContextContract) {
// console.log({
// registerBody: request.body(),
// });
await request.validate(AuthValidator);
const plainPassword = await request.input('password');
const email = await request.input('email');
// grab uid and password values off request body
// const { email, password } = request.only(['email', 'password'])
try {
// attempt to verify credential and login user
await auth.use('web').attempt(email, plainPassword);
// const user = await auth.use('web').verifyCredentials(email, plainPassword);
// if (user.isTwoFactorEnabled) {
// // session.put("login.id", user.id);
// // return view.render("pages/two-factor-challenge");
// }
// session.forget('login.id');
// session.regenerate();
// await auth.login(user);
} catch (error) {
// if login fails, return vague form message and redirect back
session.flash('message', 'Your username, email, or password is incorrect');
return response.redirect().back();
}
// otherwise, redirect todashboard
response.redirect('/apps/dashboard');
}
// logout function
public async logout({ auth, response }: HttpContextContract) {
// await auth.logout();
await auth.use('web').logout();
response.redirect('/app/login');
// return response.status(200);
}
}