Skip to content

Commit

Permalink
Update ilios-jwt authenticator for ESA-token v4
Browse files Browse the repository at this point in the history
ember-simple-auth-token v4 simplified the API and we needed to make some
changes to our custom authenticator to handle them.
  • Loading branch information
jrjohnson committed Aug 24, 2018
1 parent cca6513 commit d0e986d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 3 additions & 5 deletions app/authenticators/ilios-jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ export default JwtTokenAuthenticator.extend({
response[this.tokenPropertyName] = token;
response[this.tokenExpireName] = expiresAt;

resolve(this.getResponseData(response));
resolve(response);
} else {
var data = this.getAuthenticateData(credentials);

this.makeRequest(this.serverTokenEndpoint, data, headers).then(response => {
this.makeRequest(this.serverTokenEndpoint, credentials, headers).then(response => {
const token = get(response, this.tokenPropertyName);
const tokenData = this.getTokenData(token);
const expiresAt = get(tokenData, this.tokenExpireName);
const tokenExpireData = {};
this.scheduleAccessTokenRefresh(expiresAt, token);
tokenExpireData[this.tokenExpireName] = expiresAt;
response = merge(response, tokenExpireData);
resolve(this.getResponseData(response));
resolve(response);
}, e => {
let error = {
'message': e.message,
Expand Down
4 changes: 2 additions & 2 deletions app/components/login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default Component.extend({
errors: null,
noAccountExistsError: false,
noAccountExistsAccount: null,
identification: null,
username: null,
password: null,
authenticate: task(function* () {
try {
this.set('errors', []);
const credentials = this.getProperties('identification', 'password');
const credentials = this.getProperties('username', 'password');
const session = this.get('session');
const authenticator = 'authenticator:ilios-jwt';
yield session.authenticate(authenticator, credentials);
Expand Down
8 changes: 4 additions & 4 deletions app/templates/components/login-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
{{/each}}
<form {{action (perform authenticate) on="submit"}}>
<div class="item">
<label for={{concat elementId "-identification-input"}}>{{t "general.username"}}:</label>
<label for={{concat elementId "-username-input"}}>{{t "general.username"}}:</label>
<input
id={{concat elementId "-identification-input"}}
id={{concat elementId "-username-input"}}
type="text"
autocorrect="off"
autocapitalize="off"
value={{identification}}
oninput={{action (mut identification) value="target.value"}}
value={{username}}
oninput={{action (mut username) value="target.value"}}
>
</div>
<div class="item">
Expand Down

0 comments on commit d0e986d

Please sign in to comment.