strapi-plugin-passwordless
Version:
A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email.
57 lines (47 loc) • 999 B
JavaScript
;
/**
* passwordless.js controller
*
* @description: A set of functions called "actions" of the `passwordless` plugin.
*/
const _ = require("lodash");
module.exports = {
/**
* Default action.
*
* @return {Object}
*/
index: async (ctx) => {
// Add your own logic here.
// Send 200 `ok`
ctx.send({
message: 'ok'
});
},
async getSettings(ctx) {
ctx.send({
settings: await strapi
.store({
environment: '',
type: 'plugin',
name: 'passwordless',
key: 'settings',
})
.get(),
});
},
async updateSettings(ctx) {
if (_.isEmpty(ctx.request.body)) {
return ctx.badRequest(null, [{ messages: [{ id: 'Cannot be empty' }] }]);
}
await strapi
.store({
environment: '',
type: 'plugin',
name: 'passwordless',
key: 'settings',
})
.set({ value: ctx.request.body });
ctx.send({ ok: true });
},
};