Update account service references
This commit is contained in:
parent
52979ac9e2
commit
bbcef5459e
18 changed files with 56 additions and 25 deletions
|
@ -3,6 +3,9 @@ import Ember from 'ember';
|
|||
export default Ember.Component.extend({
|
||||
classNames: ["flakes-frame"],
|
||||
|
||||
session: Ember.inject.service('session'),
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
didInsertElement: function() {
|
||||
FlakesFrame.init();
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{{#link-to 'protected.characteristics' tagName='li' href=false}}
|
||||
{{link-to 'Characteristics' 'protected.characteristics'}}
|
||||
{{/link-to}}
|
||||
{{#if session.currentUser.isAdmin}}
|
||||
{{#if currentUser.account.isAdmin}}
|
||||
{{#link-to 'protected.users' tagName='li' href=false}}
|
||||
{{link-to 'Users' 'protected.users'}}
|
||||
{{/link-to}}
|
||||
|
@ -24,7 +24,7 @@
|
|||
{{/link-to}}
|
||||
</ul>
|
||||
<p class="foot">
|
||||
{{link-to session.currentUser.name 'protected.users.show' session.currentUser.id}}<br>
|
||||
{{link-to currentUser.account.name 'protected.users.show' currentUser.account.id}}<br>
|
||||
<a {{action 'invalidateSession'}}>Logout</a>
|
||||
</p>
|
||||
{{else}}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.characteristics.index');
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
model: function() {
|
||||
return this.store.findAll('characteristic');
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.characteristics.index');
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.species.index');
|
||||
}
|
||||
|
@ -18,7 +20,7 @@ export default Ember.Route.extend({
|
|||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
model: function() {
|
||||
return this.store.findAll('species');
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.species.index');
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.strains.index');
|
||||
}
|
||||
|
@ -26,7 +27,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
|
||||
setupController: function(controller, models) {
|
||||
controller.setProperties(models);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
model: function() {
|
||||
return this.store.findAll('strain');
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('isReader')) {
|
||||
this.transitionTo('protected.strains.index');
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ import Ember from 'ember';
|
|||
import ajaxRequest from '../../../../utils/ajax-request';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
passwordConfirm: null,
|
||||
|
||||
actions: {
|
||||
|
@ -16,7 +18,7 @@ export default Ember.Controller.extend({
|
|||
let options = {
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: this.get('session.currentUser.id'),
|
||||
id: this.get('currentUser.account.id'),
|
||||
password: this.get('password'),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
|
||||
let user_id = transition.params['protected.users.changepassword'].user_id;
|
||||
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('id') !== user_id) {
|
||||
this.transitionTo('protected.users.index');
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
|
||||
let user_id = transition.params['protected.users.edit'].user_id;
|
||||
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (user.get('id') !== user_id && !user.get('isAdmin')) {
|
||||
this.transitionTo('protected.users.index');
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{{
|
||||
protected/users/user-form
|
||||
user=model
|
||||
currentUser=session.currentUser
|
||||
currentUser=currentUser.account
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.get('session.currentUser').then((user) => {
|
||||
this.get('currentUser.account').then((user) => {
|
||||
if (!user.get('isAdmin')) {
|
||||
this.transitionTo('protected.index');
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isUser: Ember.computed('model.id', 'session.currentUser.id', function() {
|
||||
return this.get('model.id') === this.get('session.currentUser.id');
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
isUser: Ember.computed('model.id', 'currentUser.account.id', function() {
|
||||
return this.get('model.id') === this.get('currentUser.account.id');
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
|
||||
this.get('session.currentUser').then((currentUser) => {
|
||||
this.get('currentUser.account').then((currentUser) => {
|
||||
let user_id = transition.params['protected.users.show'].user_id;
|
||||
if (!currentUser.get('isAdmin') && currentUser.get('id') !== user_id) {
|
||||
this.transitionTo('protected.users.index');
|
||||
|
|
Reference in a new issue