setup base jwt authentication
This commit is contained in:
34
app/controllers/login.js
Normal file
34
app/controllers/login.js
Normal file
@@ -0,0 +1,34 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user