UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 924 B
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../../libs/repositories/users.mjs";import{invalidateAuthCache as n}from"../auth/helpers/auth-cache.mjs";import r from"./checks/check-not-last-user.mjs";import i from"./checks/check-user-access.mjs";const a=async(a,o)=>{let s=new t(a.db.client,a.config.db);if(o.currentUserId===o.userId)return{error:{type:`basic`,message:e(`server:core.users.self.delete.denied`),status:400},data:void 0};let c=await i(a,{id:o.userId});if(c.error)return c;let l=await r(a);if(l.error)return l;let u=await s.updateSingle({data:{is_deleted:!0,is_deleted_at:new Date().toISOString(),deleted_by:o.currentUserId},where:[{key:`id`,operator:`=`,value:o.userId}],returning:[`id`,`first_name`,`last_name`,`email`],validation:{enabled:!0,defaultError:{status:500}}});return u.error?u:(await n(a),{error:void 0,data:void 0})};export{a as default}; //# sourceMappingURL=delete-single.mjs.map