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