0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00

Merge pull request #3406 from simplabs/update-ember-simple-auth

Updated Ember Simple Auth to latest version
This commit is contained in:
Hannah Wolfe 2014-07-26 17:24:18 +01:00
commit 1cff73f36c
24 changed files with 41 additions and 38 deletions

View file

@ -441,8 +441,8 @@ var path = require('path'),
'bower_components/jquery-file-upload/js/jquery.fileupload.js',
'bower_components/fastclick/lib/fastclick.js',
'bower_components/nprogress/nprogress.js',
'bower_components/ember-simple-auth/ember-simple-auth.js',
'bower_components/ember-simple-auth/ember-simple-auth-oauth2.js',
'bower_components/ember-simple-auth/simple-auth.js',
'bower_components/ember-simple-auth/simple-auth-oauth2.js',
'core/shared/lib/showdown/extensions/ghostimagepreview.js',
'core/shared/lib/showdown/extensions/ghostgfm.js'

View file

@ -8,7 +8,7 @@
"ember-data": "~1.0.0-beta.8",
"ember-load-initializers": "git://github.com/stefanpenner/ember-load-initializers.git#0.0.1",
"ember-resolver": "git://github.com/stefanpenner/ember-jj-abrams-resolver.git#181251821cf513bb58d3e192faa13245a816f75e",
"ember-simple-auth": "git://github.com/simplabs/ember-simple-auth-component.git#0.5.3",
"ember-simple-auth": "0.6.4",
"fastclick": "1.0.0",
"ghost-ui": "~0.8.0",
"handlebars": "1.3.0",

View file

@ -27,6 +27,7 @@
"Em": true,
"DS": true,
"$": true,
"SimpleAuth": true,
"validator": true,
"ic": true,
"_": true,

View file

@ -32,12 +32,12 @@ var SetupController = Ember.ObjectController.extend(ValidationEngine, {
}]
}
}).then(function () {
self.get('session').authenticate('ember-simple-auth-authenticator:oauth2-password-grant', {
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
identification: self.get('email'),
password: self.get('password')
}).then(function () {
self.send('signedIn');
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
self.transitionToRoute(SimpleAuth.Configuration.routeAfterAuthentication);
});
}, function (resp) {
self.toggleProperty('submitting');

View file

@ -1,7 +1,7 @@
import ValidationEngine from 'ghost/mixins/validation-engine';
var SigninController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, ValidationEngine, {
authenticatorFactory: 'ember-simple-auth-authenticator:oauth2-password-grant',
var SigninController = Ember.Controller.extend(SimpleAuth.LoginControllerMixin, ValidationEngine, {
authenticator: 'simple-auth-authenticator:oauth2-password-grant',
validationType: 'signin',

View file

@ -33,12 +33,12 @@ var SignupController = Ember.ObjectController.extend(ValidationEngine, {
}]
}
}).then(function () {
self.get('session').authenticate('ember-simple-auth-authenticator:oauth2-password-grant', {
self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', {
identification: self.get('email'),
password: self.get('password')
}).then(function () {
self.send('signedIn');
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
self.transitionToRoute(SimpleAuth.Configuration.routeAfterAuthentication);
});
}, function (resp) {
self.toggleProperty('submitting');

View file

@ -1,27 +1,29 @@
var AuthenticationInitializer = {
name: 'authentication',
before: 'simple-auth',
after: 'registerTrailingLocationHistory',
initialize: function (container, application) {
Ember.SimpleAuth.Session.reopen({
initialize: function (container) {
window.ENV = window.ENV || {};
window.ENV['simple-auth'] = {
authenticationRoute: 'signin',
routeAfterAuthentication: 'content',
authorizer: 'simple-auth-authorizer:oauth2-bearer'
};
SimpleAuth.Session.reopen({
user: function () {
return container.lookup('store:main').find('user', 'me');
}.property()
});
Ember.SimpleAuth.Authenticators.OAuth2.reopen({
SimpleAuth.Authenticators.OAuth2.reopen({
serverTokenEndpoint: '/ghost/api/v0.1/authentication/token',
refreshAccessTokens: true,
makeRequest: function (data) {
makeRequest: function (url, data) {
data.client_id = 'ghost-admin';
return this._super(data);
return this._super(url, data);
}
});
Ember.SimpleAuth.setup(container, application, {
authenticationRoute: 'signin',
routeAfterAuthentication: 'content',
authorizerFactory: 'ember-simple-auth-authorizer:oauth2-bearer'
});
}
};

View file

@ -1,6 +1,6 @@
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
var ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin, ShortcutsRoute, {
var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, ShortcutsRoute, {
shortcuts: {
'esc': 'closePopups'

View file

@ -1,7 +1,7 @@
import styleBody from 'ghost/mixins/style-body';
import loadingIndicator from 'ghost/mixins/loading-indicator';
var DebugRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
var DebugRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
classNames: ['settings'],
beforeModel: function () {

View file

@ -1,6 +1,6 @@
import base from 'ghost/mixins/editor-route-base';
var EditorEditRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, base, {
var EditorEditRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, base, {
classNames: ['editor'],
model: function (params) {

View file

@ -1,6 +1,6 @@
import base from 'ghost/mixins/editor-route-base';
var EditorNewRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, base, {
var EditorNewRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, base, {
classNames: ['editor'],
model: function () {

View file

@ -9,7 +9,7 @@ var paginationSettings = {
page: 1
};
var PostsRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, ShortcutsRoute, styleBody, loadingIndicator, PaginationRouteMixin, {
var PostsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, ShortcutsRoute, styleBody, loadingIndicator, PaginationRouteMixin, {
classNames: ['manage'],
model: function () {

View file

@ -1,6 +1,6 @@
import loadingIndicator from 'ghost/mixins/loading-indicator';
var PostsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
var PostsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
// This route's only function is to determine whether or not a post
// exists to be used for the content preview. It has a parent resource (Posts)
// that is responsible for populating the store.

View file

@ -1,7 +1,7 @@
import loadingIndicator from 'ghost/mixins/loading-indicator';
import ShortcutsRoute from 'ghost/mixins/shortcuts-route';
var PostsPostRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, ShortcutsRoute, {
var PostsPostRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, ShortcutsRoute, {
model: function (params) {
var self = this,
post,

View file

@ -1,7 +1,7 @@
import styleBody from 'ghost/mixins/style-body';
import loadingIndicator from 'ghost/mixins/loading-indicator';
var SettingsRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
var SettingsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
classNames: ['settings']
});

View file

@ -1,4 +1,4 @@
var AppsRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, {
var AppsRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, {
beforeModel: function () {
if (!this.get('config.apps')) {
this.transitionTo('settings.general');

View file

@ -1,6 +1,6 @@
import loadingIndicator from 'ghost/mixins/loading-indicator';
var SettingsGeneralRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
var SettingsGeneralRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, loadingIndicator, {
model: function () {
return this.store.find('setting', { type: 'blog,theme' }).then(function (records) {
return records.get('firstObject');

View file

@ -1,6 +1,6 @@
import {mobileQuery} from 'ghost/utils/mobile';
var SettingsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, {
var SettingsIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, {
// redirect to general tab, unless on a mobile phone
beforeModel: function () {
if (!mobileQuery.matches) {

View file

@ -1,3 +1,3 @@
var UsersRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin);
var UsersRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin);
export default UsersRoute;

View file

@ -6,7 +6,7 @@ var paginationSettings = {
status: 'all'
};
var UsersIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, PaginationRouteMixin, {
var UsersIndexRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, PaginationRouteMixin, {
setupController: function (controller, model) {
this._super(controller, model);
this.setupPagination(paginationSettings);

View file

@ -12,7 +12,7 @@ var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
// If user is logged in, setup has already been completed.
if (this.get('session').isAuthenticated) {
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
this.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
return;
}

View file

@ -5,7 +5,7 @@ var SigninRoute = Ember.Route.extend(styleBody, loadingIndicator, {
classNames: ['ghost-login'],
beforeModel: function () {
if (this.get('session').isAuthenticated) {
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
this.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
}
},
actions: {
@ -22,7 +22,7 @@ var SigninRoute = Ember.Route.extend(styleBody, loadingIndicator, {
attemptedTransition.retry();
self.get('session').set('attemptedTransition', null);
} else {
self.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
self.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
}
});
},

View file

@ -1,13 +1,13 @@
import styleBody from 'ghost/mixins/style-body';
import loadingIndicator from 'ghost/mixins/loading-indicator';
var SignoutRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
var SignoutRoute = Ember.Route.extend(SimpleAuth.AuthenticatedRouteMixin, styleBody, loadingIndicator, {
classNames: ['ghost-signout'],
afterModel: function (resolvedModel, transition) {
if (Ember.canInvoke(transition, 'send')) {
transition.abort();
transition.send('invalidateSession');
transition.abort();
this.transitionTo('signin');
} else {
this.send('invalidateSession');

View file

@ -5,7 +5,7 @@ var SignupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
classNames: ['ghost-signup'],
beforeModel: function () {
if (this.get('session').isAuthenticated) {
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
this.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
}
},
setupController: function (controller, params) {