From aec17dd4ef8af9405a155397ae17e814828eb972 Mon Sep 17 00:00:00 2001 From: bobrimperator Date: Sun, 29 Dec 2024 04:27:30 +0100 Subject: [PATCH] doc(ember-simple-auth): start writing a migration guide --- guides/upgrade-to-v7.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 guides/upgrade-to-v7.md diff --git a/guides/upgrade-to-v7.md b/guides/upgrade-to-v7.md new file mode 100644 index 000000000..82e77ac78 --- /dev/null +++ b/guides/upgrade-to-v7.md @@ -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`; +} +```