import env from '#start/env'; export default class AuthController { async showLogin({ view, session, response }) { if (session.get('is_authenticated')) { return response.redirect().toPath('/'); } return view.render('login'); } async login({ request, session, response }) { const { username, password } = request.only(['username', 'password']); const validUsername = env.get('AUTH_USERNAME'); const validPassword = env.get('AUTH_PASSWORD'); if (username === validUsername && password === validPassword) { session.put('is_authenticated', true); session.put('username', username); const intendedUrl = session.get('intended_url', '/'); session.forget('intended_url'); return response.redirect().toPath(intendedUrl); } session.flash('errors', { form: 'Invalid username or password.' }); session.flashOnly(['username']); return response.redirect().toPath('/login'); } async logout({ session, response }) { session.clear(); return response.redirect().toPath('/login'); } } //# sourceMappingURL=auth_controller.js.map