Skip to content

Commit

Permalink
avniproject/avni-server#841 - add token to the params
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Dec 26, 2024
1 parent f4f4baf commit aeb2a52
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {Groups, ReportCardResult, NestedReportCardResult} from "openchs-models";
import {JSONStringify} from "../utility/JsonStringify";
import UserInfoService from "./UserInfoService";
import PrivilegeService from './PrivilegeService';
import AuthService from "./AuthService";

function getImports() {
return {rulesConfig, common, lodash, moment, motherCalculations, log: console.log};
Expand Down Expand Up @@ -479,9 +480,11 @@ class RuleEvaluationService extends BaseService {
async validateViaFormRuleAsyncInternal(form, entity, entityContext, entityName) {
try {
let ruleServiceLibraryInterfaceForSharingModules = this.getRuleServiceLibraryInterfaceForSharingModules();
const authService = this.context.getService(AuthService);
const authToken = await authService.getAuthProviderService().getAuthToken();
const ruleFunc = eval(form.validationRule);
return ruleFunc({
params: _.merge({entity, entityContext, services: this.services}, this.getCommonParams()),
params: _.merge({entity, entityContext, services: this.services, authToken: authToken}, this.getCommonParams()),
imports: getImports()
});
} catch (e) {
Expand Down

0 comments on commit aeb2a52

Please sign in to comment.