Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/access-strategy-types/logged_in.js
"use strict"; | |||||
const Promise = require("bluebird"); | const Promise = require("bluebird"); | ||||
const Query = require("../../../datastore/query.js"); | const Query = require("../../../datastore/query.js"); | ||||
module.exports = { | module.exports = { | ||||
name: "logged_in", | name: "logged_in", | ||||
getRestrictingQuery: async function(context) { | async getRestrictingQuery(context) { | ||||
if (context.user_id) { | if (context.user_id) { | ||||
return new Query.AllowAll(); | return new Query.AllowAll(); | ||||
} | } | ||||
return new Query.DenyAll(); | return new Query.DenyAll(); | ||||
}, | }, | ||||
checker_function: function(context) { | checker_function(context) { | ||||
if (context.user_id) { | if (context.user_id) { | ||||
return Promise.resolve(); | return Promise.resolve(); | ||||
} else { | |||||
return Promise.reject( | |||||
"Only logged-in users can perform this action." | |||||
); | |||||
} | } | ||||
return Promise.reject("Only logged-in users can perform this action."); | |||||
}, | }, | ||||
}; | }; |