oak-general-business/lib/triggers/applicationPassport.js

33 lines
1.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("oak-domain/lib/utils/assert");
const triggers = [
{
name: '当loginName类型的applicationPassport创建前将其allowPwd置为ture',
entity: 'applicationPassport',
action: 'create',
when: 'before',
fn: async ({ operation }, context, option) => {
const { data } = operation;
(0, assert_1.assert)(!(data instanceof Array));
const [passport] = await context.select('passport', {
data: {
id: 1,
type: 1,
},
filter: {
id: data?.passportId,
}
}, {
forUpdate: true,
});
const { type } = passport || {};
if (type === 'loginName' && !data.allowPwd) {
data.allowPwd = true;
}
return 1;
}
},
];
exports.default = triggers;