Skip to content
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

Store attemptedTransition target url as a cookie in fastboot mode #1136

Merged
merged 1 commit into from
Dec 19, 2016

Conversation

DrewCarlson
Copy link
Contributor

Fixes #1127

Copy link
Member

@marcoow marcoow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! There are a few things that should be cleaned up a bit to make sure we're adding less weight to routes including the mixins but apart from that this is great - thanks!

@@ -58,6 +58,10 @@ export default Mixin.create({
return fastboot ? fastboot.get('isFastBoot') : false;
}),

_cookies: computed(function() {
return getOwner(this).lookup('service:cookies');
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should lookup the service inside of the sessionAuthenticated method so that we don't add any unnecessary properties via the mixin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had _cookies and _secureCookies as members strictly for mocking in tests. Is there a reference in the test suite for mocking the lookup function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes testing easier for sure. There should be examples in the code base where the container is mocked though.

@@ -33,12 +33,25 @@ export default Mixin.create({
*/
session: service('session'),

_cookies: computed(function() {
return getOwner(this).lookup('service:cookies');
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should lookup the service inside of the sessionAuthenticated method so that we don't add any unnecessary properties via the mixin.

}

return window.location.protocol === 'https:';
}).volatile(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this into the sessionAuthenticated method so that we don't add any unnecessary properties via the mixin. Also this will only ever be used when running in FastBoot so window.location.protocol can be ignored.

if (!this.get('_isFastBoot')) {
if (this.get('_isFastBoot')) {
this.get('_cookies').write('ember_simple_auth-redirectTarget', transition.intent.url, {
path: `/${authenticationRoute}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authenticationRoute will be the Ember route and would contain dots instead of slashes (e.g. app.internal.login instead of app/internal/login). Is there any way we can get the URL path for the Ember route? If not I think we'll have to set the path to /.


beforeEach(() => {
session = InternalSession.create({ store: EphemeralStore.create() });
cookiesMock = {
read() {},
write() {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write shouldn't actually be needed here.

@DrewCarlson
Copy link
Contributor Author

@marcoow I don't see a simple way to resolve the route's path from name. Let me know if you have any thoughts or other requests.

@marcoow
Copy link
Member

marcoow commented Dec 19, 2016

Yeah, it's probably fine to simply set the path to /.

@marcoow marcoow added this to the 1.2 milestone Dec 19, 2016
@marcoow marcoow merged commit 2078be3 into mainmatter:master Dec 19, 2016
@marcoow
Copy link
Member

marcoow commented Dec 19, 2016

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants