You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-30 23:44:55 +02:00
17 lines
625 B
TypeScript
17 lines
625 B
TypeScript
import { Session } from '../../db';
|
|
import { ErrorForbidden } from '../../utils/errors';
|
|
import uuidgen from '../../utils/uuidgen';
|
|
import BaseController from '../BaseController';
|
|
|
|
export default class SessionController extends BaseController {
|
|
|
|
public async authenticate(email: string, password: string): Promise<Session> {
|
|
const userModel = this.models.user();
|
|
const user = await userModel.login(email, password);
|
|
if (!user) throw new ErrorForbidden('Invalid username or password');
|
|
const session: Session = { id: uuidgen(), user_id: user.id };
|
|
return this.models.session().save(session, { isNew: true });
|
|
}
|
|
|
|
}
|