meilisearch-admin/app/controllers/login.js
2022-08-20 09:35:34 +03:00

38 lines
852 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:oauth2',
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;
}
}