芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/api/session/services/session.js
'use strict'; /** * Read the documentation (https://strapi.io/documentation/v3.x/concepts/services.html#core-services) * to customize this service */ module.exports = { async canAccessResources(user,levels,thisLevelId){ const isAdmin = strapi.services.helpers.isAdmin(user); if (!isAdmin){ const ids = levels.map(x => x.id); ids.push(thisLevelId); let userCourse= await strapi.query("user-course").find({ user:user.id,isConfirm:true,course_levels_in:ids }); if (userCourse===null || userCourse.length===0){ return { result: false, entity: "course.errors.courseNotFound" }; } userCourse= userCourse[0]; let expiredDate = userCourse.expiredDate; if (!expiredDate){ expiredDate= strapi.services.helpers.addDays(userCourse.factorDate,366); }else{ expiredDate= new Date(expiredDate); } if (expiredDate.getTime() < new Date().getTime()){ return { result: false, entity: "course.errors.usingIsExpired" }; } return { result:true, entity: levels, userCourse, } } return { result: true, entity: levels }; } };