2022-11-22 13:29:42 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethodCtx('unlock', {
|
|
|
|
description: 'Unlock an app for the user',
|
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [
|
|
|
|
{
|
|
|
|
arg: 'appName',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
description: 'The app name',
|
|
|
|
http: {source: 'path'}
|
|
|
|
|
|
|
|
}
|
|
|
|
],
|
|
|
|
returns: {
|
|
|
|
type: ['object'],
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/:appName/unlock`,
|
|
|
|
verb: 'POST'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-11-22 13:43:15 +00:00
|
|
|
Self.unlock = async(ctx, appName, options) => {
|
2022-11-22 13:29:42 +00:00
|
|
|
const models = Self.app.models;
|
|
|
|
const myOptions = {};
|
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2022-12-20 08:09:21 +00:00
|
|
|
const mdbApp = await models.MdbApp.findById(appName, null, myOptions);
|
|
|
|
const updatedMdbApp = await mdbApp.updateAttributes({
|
|
|
|
userFk: null,
|
|
|
|
locked: null
|
|
|
|
}, myOptions);
|
2022-11-22 13:29:42 +00:00
|
|
|
|
2022-12-20 08:09:21 +00:00
|
|
|
return updatedMdbApp;
|
2022-11-22 13:29:42 +00:00
|
|
|
};
|
|
|
|
};
|