mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
ef54fc895f
@ -49,7 +49,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
key = 'email';
|
key = 'email';
|
||||||
}
|
}
|
||||||
const user = await ctx.db.getRepository('users').findOne({
|
const UserRepo = ctx.db.getRepository('users');
|
||||||
|
const user = await UserRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
[key]: currentUser[key],
|
[key]: currentUser[key],
|
||||||
},
|
},
|
||||||
@ -59,8 +60,12 @@ export default {
|
|||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', { ns: namespace }));
|
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', { ns: namespace }));
|
||||||
}
|
}
|
||||||
user.password = newPassword;
|
await UserRepo.update({
|
||||||
await user.save();
|
filterByTk: user.id,
|
||||||
|
values: {
|
||||||
|
password: newPassword,
|
||||||
|
},
|
||||||
|
});
|
||||||
ctx.body = currentUser;
|
ctx.body = currentUser;
|
||||||
await next();
|
await next();
|
||||||
},
|
},
|
||||||
|
@ -28,7 +28,7 @@ describe('workflow > triggers > collection', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
app = await getApp({
|
app = await getApp({
|
||||||
plugins: ['error-handler', 'data-source-main', 'users', 'auth'],
|
plugins: ['error-handler', 'data-source-main', 'users', 'auth', 'system-settings'],
|
||||||
});
|
});
|
||||||
|
|
||||||
db = app.db;
|
db = app.db;
|
||||||
@ -316,6 +316,32 @@ describe('workflow > triggers > collection', () => {
|
|||||||
const executions = await workflow.getExecutions();
|
const executions = await workflow.getExecutions();
|
||||||
expect(executions.length).toBe(0);
|
expect(executions.length).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('password changed in users', async () => {
|
||||||
|
const workflow = await WorkflowModel.create({
|
||||||
|
enabled: true,
|
||||||
|
sync: true,
|
||||||
|
type: 'collection',
|
||||||
|
config: {
|
||||||
|
mode: 2,
|
||||||
|
collection: 'users',
|
||||||
|
changed: ['passwordChangeTz'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const res = await (await app.agent().login(1)).resource('auth').changePassword({
|
||||||
|
values: {
|
||||||
|
oldPassword: 'admin123',
|
||||||
|
newPassword: 'abc123',
|
||||||
|
confirmPassword: 'abc123',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(res.status).toBe(200);
|
||||||
|
|
||||||
|
const executions = await workflow.getExecutions();
|
||||||
|
expect(executions.length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('config.condition', () => {
|
describe('config.condition', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user