import { RequestHandler } from "../entities/RequestHandler"; import { AccountHelper } from "../helpers/AccountHelper"; /** * Account controller * * @author Pierre HUBERT */ export class AccountController { /** * Attempt to login user * * @param handler */ public static async LoginUser(handler: RequestHandler) { // Get post data const email = handler.postEmail("userMail"); const password = handler.postString("userPassword"); // TODO : add limits // Authenticate user const tokens = await AccountHelper.LoginUser(email, password, handler.getClientInfo()); if(tokens == null) { // TODO : add limits handler.error(401, "Invalid e-mail address / password !"); } // Success handler.send({ success: "User signed in!", tokens: { token1: tokens.token1, token2: tokens.token2 } }); } }