-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate mixins #2198
Deprecate mixins #2198
Conversation
4de50dd
to
b6704d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for putting all that work into Ember Simple Auth! To small comments on the API design. Hope it's helpful.
0e836d3
to
7b7a0b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor clarification, loving the new api <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor fix needed for the readme and this looks good to go.
hmm any ideas on why the specs are failing? |
@patsy-issa I think we're running into this: ember-cli/babel-plugin-ember-modules-api-polyfill#64 (it's also broken on |
@marcoow - ember-cli-babel@7.20.1 was just released, and should fix the underlying issue referenced in ember-cli/babel-plugin-ember-modules-api-polyfill#64. https://github.com/babel/ember-cli-babel/releases/tag/v7.20.1 |
Thanks @rwjblue ❤️ |
Unfortunately we're running into ember-cli/babel-plugin-ember-modules-api-polyfill#110 now… |
@patsy-issa CI is green now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see this merged. Thanks for the amazing work! Any idea when we can expect a release? |
@pjcarly we released a beta version including this today. 🎉 |
This PR deprecates the mixins and introduces a new API that is exposed completely via the
session
service.We discussed a few options for replacing the current mixins with a new mechanism in #2185 (thanks to everyone who chimed in!) but focussed mostly on concepts that would replace the mixins directly. Since we have dropped support for older versions of Ember though and now have new capabilities that we can leverage that were not available when ESA's current mixin mechanism was first introduced, I realized we could build a completely new API.
Historically, transitioning between routes was only really possible from route classes (or controllers) since there was no routing service. For that reason, we had to establish a connection between the session and its change state on one side and the routes on the other side. With the routing service that is no longer necessary though as we can transition between routes from the session directly using the service. That means we can just drop the
ApplicationRouteMixin
that implemented the above described connection between the routing layer and the session and handle all of that in thesession
itself. We still maintain customizability of course since any app can simply extend the session service and override the respective methods, similar to how you would do the same thing in the application route currently.The
AuthenticatedRouteMixin
's andUnauthenticatedRouteMixin
's main responsibilities were adding custom logic into the route classes'beforeModel
methods that would check for the session to be authenticated or not and transition elsewhere etc. A mixin is a nice way to share that code and automatically put it in the right place. While exposing that API via the session service now will require a bit more code, it still doesn't put significant additional cognitive load on the developer and it's easy to extract the code into a base class if one wanted to do that:The opposite of this would be
this.session.prohibitAuthentication('index')
for disallowing a route to be visited when the session is authenticated already.The
OAuth2ImplicitGrantCallbackRouteMixin
andDataAdapterMixin
mixins are deprecated without 1:1 replacements. They provide very little value anyway and would usually only be used once per application. Thus, adding guidance in the docs for achieving the respective behavior should be sufficient.TODO
DataAdapterMixin
OAuth2ImplicitGrantCallbackRouteMixin
closes #2185