Skip to content

Commit

Permalink
Merge pull request #2892 from mainmatter/test-esa-via-link
Browse files Browse the repository at this point in the history
chore(deps): specify ember-simple-auth as a link for test-apps
  • Loading branch information
BobrImperator authored Dec 29, 2024
2 parents 6f86a3d + ca7b19c commit ecb800f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 46 deletions.
34 changes: 34 additions & 0 deletions guides/upgrade-to-v7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### tl;dr

Release 7.0.0 doesn't contain any new features and the API haven't really changed.
It focuses on housekeeping, modernizing the codebase and introducing Typescript to our library.
The biggest change was getting rid of as much "classic" Ember syntax as possible and get onto ES6 classes.

### Extending ember-simple-auth's classes

Most if not all of the public API is ES6 classes, as a result you'll have to change how ESA's classes are extended in your codebases.
Here's an example based on the OAuth2PasswordGrant authenticator.

Old

```js
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import config from '../config/environment';

export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: `${config.apiHost}/token`,
serverTokenRevocationEndpoint: `${config.apiHost}/revoke`,
});
```

New

```js
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import config from '../config/environment';

export default class OAuth2 extends OAuth2PasswordGrant {
serverTokenEndpoint = `${config.apiHost}/token`;
serverTokenRevocationEndpoint = `${config.apiHost}/revoke`;
}
```
8 changes: 4 additions & 4 deletions packages/classic-test-app/app/authenticators/oauth2.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
import config from '../config/environment';

export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: `${config.apiHost}/token`,
serverTokenRevocationEndpoint: `${config.apiHost}/revoke`,
});
export default class OAuth2 extends OAuth2PasswordGrant {
serverTokenEndpoint = `${config.apiHost}/token`;
serverTokenRevocationEndpoint = `${config.apiHost}/revoke`;
}
3 changes: 2 additions & 1 deletion packages/classic-test-app/app/components/login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export default Component.extend({
await this.get('session').authenticate('authenticator:oauth2', identification, password);

if (this.rememberMe) {
this.get('session').set('store.cookieExpirationTime', 60 * 60 * 24 * 14);
this.get('session').set('cookieExpirationTime', 60 * 60 * 24 * 14);
}
} catch (response) {
console.error(response.toString());
this.set('errorMessage', response.toString());
}
}),
Expand Down
5 changes: 4 additions & 1 deletion packages/classic-test-app/app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';

export default Controller.extend({
router: service(),

actions: {
transitionToLoginRoute() {
this.transitionToRoute('login');
this.router.transitionTo('login');
},
},
});
2 changes: 1 addition & 1 deletion packages/classic-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"ember-maybe-import-regenerator": "1.0.0",
"ember-qunit": "7.0.0",
"ember-resolver": "11.0.1",
"ember-simple-auth": "6.1.0",
"ember-simple-auth": "link:../ember-simple-auth",
"ember-source": "5.12.0",
"ember-source-channel-url": "3.0.0",
"ember-try": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"ember-maybe-import-regenerator": "1.0.0",
"ember-qunit": "7.0.0",
"ember-resolver": "11.0.1",
"ember-simple-auth": "workspace:*",
"ember-simple-auth": "link:../ember-simple-auth",
"ember-source": "5.12.0",
"ember-source-channel-url": "3.0.0",
"ember-try": "3.0.0",
Expand Down
41 changes: 3 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ecb800f

Please sign in to comment.