2018-05-12 21:12:28 +02:00
|
|
|
import * as program from 'commander';
|
|
|
|
|
|
|
|
import { AuthResult } from 'jslib/models/domain/authResult';
|
|
|
|
|
|
|
|
import { AuthService } from 'jslib/abstractions/auth.service';
|
|
|
|
|
2018-05-14 20:54:19 +02:00
|
|
|
import { Response } from '../models/response';
|
2018-05-13 03:24:28 +02:00
|
|
|
|
2018-05-14 20:54:19 +02:00
|
|
|
export class LoginCommand {
|
|
|
|
constructor(private authService: AuthService) { }
|
2018-05-12 21:12:28 +02:00
|
|
|
|
2018-05-13 06:19:14 +02:00
|
|
|
async run(email: string, password: string, cmd: program.Command) {
|
|
|
|
try {
|
|
|
|
const result = await this.authService.logIn(email, password);
|
2018-05-14 20:54:19 +02:00
|
|
|
// TODO: 2FA
|
|
|
|
return Response.success();
|
2018-05-13 06:19:14 +02:00
|
|
|
} catch (e) {
|
2018-05-15 17:08:55 +02:00
|
|
|
return Response.error(e);
|
2018-05-13 06:19:14 +02:00
|
|
|
}
|
2018-05-12 21:12:28 +02:00
|
|
|
}
|
|
|
|
}
|