35 lines
816 B
JavaScript
35 lines
816 B
JavaScript
import Controller from '@ember/controller';
|
|
import { inject as service } from '@ember/service';
|
|
import { action } from "@ember/object";
|
|
import { tracked } from "@glimmer/tracking";
|
|
|
|
export default class LoginController extends Controller {
|
|
@tracked errorMessage;
|
|
@service session;
|
|
|
|
@action
|
|
async authenticate(e) {
|
|
e.preventDefault();
|
|
let { identification, password } = this;
|
|
try {
|
|
await this.session.authenticate('authenticator:jwt', identification, password);
|
|
} catch(error) {
|
|
this.errorMessage = error.error || error;
|
|
}
|
|
|
|
if (this.session.isAuthenticated) {
|
|
// What to do with all this success?
|
|
}
|
|
}
|
|
|
|
@action
|
|
updateIdentification(e) {
|
|
this.identification = e.target.value;
|
|
}
|
|
|
|
@action
|
|
updatePassword(e) {
|
|
this.password = e.target.value;
|
|
}
|
|
}
|