Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/controllers/user-management/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ export class UserController {
}
}

@Put(":id/hide-welcome")
@ApiOperation({ summary: "Don't show welcome screen for a user again" })
@Read()
async hideWelcome(@Req() req: AuthenticatedRequest): Promise<boolean> {
const wasOk = await this.userService.hideWelcome(req.user.userId);

AuditLog.success(
ActionType.UPDATE,
User.name,
req.user.userId,
req.user.userId,
req.user.username
);

return wasOk
}

@Get(":id")
@ApiOperation({ summary: "Get one user" })
async find(
Expand Down
3 changes: 3 additions & 0 deletions src/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ export class User extends DbBaseEntity {

@Column({ default: false })
isSystemUser: boolean;

@Column({ default: false })
showWelcomeScreen: boolean;
}
14 changes: 14 additions & 0 deletions src/migration/1652342361070-welcome-screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class welcomeScreen1652342361070 implements MigrationInterface {
name = 'welcomeScreen1652342361070'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" ADD "showWelcomeScreen" boolean NOT NULL DEFAULT false`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "showWelcomeScreen"`);
}

}
13 changes: 10 additions & 3 deletions src/services/user-management/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class UserService {
const mappedUser = this.mapDtoToUser(user, dto);
mappedUser.createdBy = userId;
mappedUser.updatedBy = userId;
mappedUser.showWelcomeScreen = true;

await this.setPasswordHash(mappedUser, dto.password);

Expand All @@ -138,6 +139,7 @@ export class UserService {
async createUserFromKombit(profile: Profile): Promise<User> {
const user = new User();
await this.mapKombitLoginProfileToUser(user, profile);
user.showWelcomeScreen = true;

return await this.userRepository.save(user);
}
Expand Down Expand Up @@ -256,9 +258,9 @@ export class UserService {
take: +query.limit,
skip: +query.offset,
order: sorting,
where: {
isSystemUser: false
}
where: {
isSystemUser: false,
},
});

return {
Expand Down Expand Up @@ -294,4 +296,9 @@ export class UserService {
users: result,
};
}

async hideWelcome(id: number): Promise<boolean> {
const res = await this.userRepository.update(id, { showWelcomeScreen: false });
return !!res.affected
}
}