1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01: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:
David Leek 2024-01-25 11:19:39 +01:00 committed by GitHub
parent 8f3275ee40
commit 0045fcbcdf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View File

@ -33,7 +33,7 @@ import { TokenUserSchema } from '../openapi/spec/token-user-schema';
import PasswordMismatch from '../error/password-mismatch';
import EventService from '../features/events/event-service';
const systemUser = new User({ id: -1, username: 'system' });
import { SYSTEM_USER } from '../types';
export interface ICreateUser {
name?: string;
@ -244,7 +244,7 @@ class UserService {
return userCreated;
}
private getCreatedBy(updatedBy: IUser = systemUser) {
private getCreatedBy(updatedBy: IUser = new User(SYSTEM_USER)): string {
return updatedBy.username || updatedBy.email;
}
@ -444,7 +444,10 @@ class UserService {
async createResetPasswordEmail(
receiverEmail: string,
user: IUser = systemUser,
user: IUser = new User({
id: SYSTEM_USER.id,
username: SYSTEM_USER.username,
}),
): Promise<URL> {
const receiver = await this.getByEmail(receiverEmail);
if (!receiver) {

View 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();
};