Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { Ability } from 'ember-can';
export default Ability.extend({
session: service('session'),
model: null,
author: null,
canWrite: computed("session.isAuthenticated", function() {
return this.get("session.isAuthenticated");
}),
canEdit: computed("model.author", "session.isAuthenticated", function() {
return this.get("session.isAuthenticated") && this.get("model.author") === this.get("session.user");
}),
canChangeAuthor: computed("model.author", "author.id", function() {
return this.get("author") && this.get("model") && parseInt(this.get("author.id"), null) !== this.get("model.author");
import { Ability } from 'ember-can';
export default Ability.extend({
isLoggedIn: function() {
return this.session.get("isAuthenticated");
}.checks("write post"),
isAuthor: function(post) {
return post.get("author") === this.session.get("user");
}.checks("edit post")
});
import { Ability } from 'ember-can';
import { ability } from 'ember-can/computed';
import { get, computed } from '@ember/object';
const hasPermission = permission => (
computed('membership.permissions.@each.hasDirtyAttributes', function() {
return this._isGroupMember() && get(this, 'membership').hasPermission(permission);
}).readOnly()
);
export default Ability.extend({
membership: null,
postAbility: ability('post', 'post'),
commentAbility: ability('comment', 'comment'),
canViewDashboard: computed('membership', function() {
const isMember = this._isGroupMember();
return isMember && (get(get(this, 'membership'), 'permissions.length') > 0);
}).readOnly(),
canManageEverything: hasPermission('owner'),
canManageMembers: hasPermission('members'),
canManageLeaders: hasPermission('leaders'),
canManageSettings: hasPermission('community'),
canManageReports: hasPermission('content'),
canManageTickets: hasPermission('tickets'),
import Ember from 'ember';
import { Ability } from 'ember-can';
const { inject, computed } = Ember;
const { service } = inject;
const { alias } = computed;
export default Ability.extend({
currentUser: service(),
canView: alias('currentUser.canViewLearnerGroups'),
canEdit: alias('currentUser.canEditLearnerGroups'),
});
import { alias } from '@ember/object/computed';
import { get, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { Ability } from 'ember-can';
export default Ability.extend({
currentUser: service(),
canManage: computed('organization.owner.id', 'currentUser.user.id', function() {
return get(this, 'organization.owner.id') === get(this, 'currentUser.user.id');
}),
organization: alias('model')
});
import { alias, equal, or } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { Ability } from 'ember-can';
import projectMember from 'code-corps-ember/macros/project-member';
/**
* Ability object used to determine what the current user can do with a project
*
* @module Ability
* @extends EmberCan.Ability
*/
export default Ability.extend({
currentUser: service(),
/**
* An `ember-can` ability.
*
* Indicates if the current user can manage a project.
* Returns true if the user is the owner of the project.
* @type {Boolean}
*/
canAdminister: or('{userIsAdmin,userIsOwner}'),
/**
* An `ember-can` ability.
*
* Indicates if the current user can manage a project.
* Returns true if the user is the owner of the project.
import { Ability } from 'ember-can';
import { get, computed } from '@ember/object';
export default Ability.extend({
canEdit: computed('session.hasUser', 'model', function() {
if (!get(this, 'session.hasUser')) { return false; }
const isOwner = get(this, 'session').isCurrentUser(get(this, 'model'));
const isAdmin = get(this, 'session.account').hasRole('admin', get(this, 'model'));
return isOwner || isAdmin;
}).readOnly()
});
import { Ability } from 'ember-can';
import { get, computed } from '@ember/object';
import { readOnly } from '@ember/object/computed';
export default Ability.extend({
canWrite: readOnly('session.hasUser'),
canEdit: computed('session.hasUser', 'model.user', function() {
if (!get(this, 'session.hasUser')) { return false; }
const isOwner = get(this, 'session').isCurrentUser(get(this, 'model.user'));
const isAdmin = get(this, 'session.account').hasRole('admin', get(this, 'model'));
return isOwner || isAdmin;
}).readOnly()
});
import { Ability } from 'ember-can';
import { get, computed } from '@ember/object';
export default Ability.extend({
/**
* Determines if the sessioned user is the owner of the library entry.
* (can "edit library-entry" )
*
* @returns {Boolean}
*/
canEdit: computed('session.hasUser', 'model', 'user', function() {
if (!get(this, 'session.hasUser')) { return false; }
const user = get(this, 'user') || get(this, 'model.user') || get(this, 'model');
return get(this, 'session').isCurrentUser(user);
}).readOnly()
});
import Ember from 'ember';
import { Ability } from 'ember-can';
const { inject, computed } = Ember;
const { service } = inject;
const { alias } = computed;
export default Ability.extend({
currentUser: service(),
canView: alias('currentUser.canViewInstructorGroups'),
canEdit: alias('currentUser.canEditInstructorGroups'),
});