UNPKG

flexbiz-server

Version:

Flexible Server

4 lines (3 loc) 957 B
const model=global.getModel("tokens"),controller=require("../../controllers/controller"); module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,"token",{require_id_app:!1,sort:{note:-1,date_created:-1}});$contr_router$$.route();$contr_router$$.finding=function($user$$,$condition$$,$next$$){$condition$$.email=$user$$.email;$condition$$.once={$ne:!0};$next$$(null,$condition$$)};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$next$$("Can't create token by this way")};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){if($user$$.email!== $obj$$.email)return $next$$("You don't allow to update this token ");delete $data$$.token;delete $data$$.email;delete $data$$.once;delete $data$$.used;$next$$(null,$data$$,$obj$$)};$contr_router$$.deleting=function($user$$,$obj$$,$next$$){if($user$$.email!==$obj$$.email)return $next$$("You don't allow to delete this token ");$next$$(null,$obj$$)}};