mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-17 13:46:47 +02:00
chore: replace systemUser -1 with new -1337 system user (#5999)
## About the changes This PR replaces the old systemUser -1 in user-service.ts with the new SYSTEM_USER -1337 and adds a migration to move events created_by = -1 to -1337 ## Discussion points Does it make sense to do both of these things? Or should we skip the migration? How would this behave in a large system with hundreds of thousands of events, should this be split up?
This commit is contained in:
parent
8f3275ee40
commit
0045fcbcdf
@ -33,7 +33,7 @@ import { TokenUserSchema } from '../openapi/spec/token-user-schema';
|
|||||||
import PasswordMismatch from '../error/password-mismatch';
|
import PasswordMismatch from '../error/password-mismatch';
|
||||||
import EventService from '../features/events/event-service';
|
import EventService from '../features/events/event-service';
|
||||||
|
|
||||||
const systemUser = new User({ id: -1, username: 'system' });
|
import { SYSTEM_USER } from '../types';
|
||||||
|
|
||||||
export interface ICreateUser {
|
export interface ICreateUser {
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -244,7 +244,7 @@ class UserService {
|
|||||||
return userCreated;
|
return userCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCreatedBy(updatedBy: IUser = systemUser) {
|
private getCreatedBy(updatedBy: IUser = new User(SYSTEM_USER)): string {
|
||||||
return updatedBy.username || updatedBy.email;
|
return updatedBy.username || updatedBy.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +444,10 @@ class UserService {
|
|||||||
|
|
||||||
async createResetPasswordEmail(
|
async createResetPasswordEmail(
|
||||||
receiverEmail: string,
|
receiverEmail: string,
|
||||||
user: IUser = systemUser,
|
user: IUser = new User({
|
||||||
|
id: SYSTEM_USER.id,
|
||||||
|
username: SYSTEM_USER.username,
|
||||||
|
}),
|
||||||
): Promise<URL> {
|
): Promise<URL> {
|
||||||
const receiver = await this.getByEmail(receiverEmail);
|
const receiver = await this.getByEmail(receiverEmail);
|
||||||
if (!receiver) {
|
if (!receiver) {
|
||||||
|
14
src/migrations/20240125100000-events-system-user-old2new.js
Normal file
14
src/migrations/20240125100000-events-system-user-old2new.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.up = function (db, callback) {
|
||||||
|
db.runSql(
|
||||||
|
`
|
||||||
|
UPDATE events SET created_by_user_id = -1337 WHERE created_by_user_id = -1;
|
||||||
|
`,
|
||||||
|
callback,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function (db, callback) {
|
||||||
|
callback();
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user