-
Notifications
You must be signed in to change notification settings - Fork 605
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
fix: Incorrect path to fetch the routeAfterAuthentication property in the config object #2215
fix: Incorrect path to fetch the routeAfterAuthentication property in the config object #2215
Conversation
da8bb23
to
d2efa60
Compare
e1ccbc9
to
ea46ba2
Compare
ea46ba2
to
3dd53fc
Compare
I think this might be a misunderstanding – we actually want the configuration to be 'ember-simple-auth': {
routeAfterAuthentication: '/some-route'
} in |
@marcoow I made this pr because in the app folder of the addon for the initializer, it is grabbing the ember simple auth config and not the entire ENV config object(which makes sense to me). If it was the latter, then
I could update the initializer to just use the entire Env config if that is what you were going for. Here is the code in question
import ENV from '../config/environment';
import Configuration from 'ember-simple-auth/configuration';
import setupSession from 'ember-simple-auth/initializers/setup-session';
import setupSessionService from 'ember-simple-auth/initializers/setup-session-service';
import setupSessionRestoration from 'ember-simple-auth/initializers/setup-session-restoration';
export default {
name: 'ember-simple-auth',
initialize(registry) {
const config = ENV['ember-simple-auth'] || {};
config.rootURL = ENV.rootURL || ENV.baseURL;
Configuration.load(config);
setupSession(registry);
setupSessionService(registry);
setupSessionRestoration(registry);
}
}; Notice how you are already grabbing the ember simple auth config which means you dont need to reference the key |
@marcoow Tell me if this is more what you were going for.
import ENV from '../config/environment';
import Configuration from 'ember-simple-auth/configuration';
import setupSession from 'ember-simple-auth/initializers/setup-session';
import setupSessionService from 'ember-simple-auth/initializers/setup-session-service';
import setupSessionRestoration from 'ember-simple-auth/initializers/setup-session-restoration';
export default {
name: 'ember-simple-auth',
initialize(registry) {
Configuration.load(ENV);
setupSession(registry);
setupSessionService(registry);
setupSessionRestoration(registry);
}
};
import { getWithDefault } from '@ember/object';
const DEFAULTS = {
rootURL: '',
routeAfterAuthentication: 'index',
};
/**
Ember Simple Auth's configuration object.
@class Configuration
@extends Object
@module ember-simple-auth/configuration
@public
*/
export default {
/**
The root URL of the application as configured in `config/environment.js`.
@property rootURL
@readOnly
@static
@type String
@default ''
@public
*/
rootURL: DEFAULTS.rootURL,
/**
The route to transition to after successful authentication.
@property routeAfterAuthentication
@readOnly
@static
@type String
@default 'index'
@public
*/
routeAfterAuthentication: DEFAULTS.routeAfterAuthentication,
load(config) {
this.rootURL = config.rootURL || config.baseURL || DEFAULTS.rootURL;
this.routeAfterAuthentication = getWithDefault(config, 'ember-simple-auth.routeAfterAuthentication', DEFAULTS.routeAfterAuthentication);
}
}; |
@marcoow Based on your comment, I reverted back how the test was and passed in the Entire ENV config object in the |
Ah, sorry my comment was wrong of course and what you were saying initially is completely correct – this is in fact a bug. Can you remove the last commit though? I think the original fix is better. Sorry for the confusion! |
744bd5a
to
3dd53fc
Compare
@marcoow Alright, I've reverted to the previous commit as you asked. Pull request should be ready to go. |
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!
@marcoow Any chance we could get a new release with this fix? |
Simple fix to properly get the
routeAfterAuthentication
property from theconfig
object upon application load.