refactor(nestjs): hook up auth endpoints

This commit is contained in:
Ahmed Bouhuolia
2025-05-08 18:10:02 +02:00
parent 401b3dc111
commit f78d6efe27
26 changed files with 304 additions and 111 deletions

View File

@@ -1,6 +1,6 @@
import { DashboardService } from './Dashboard.service';
import { Controller, Get } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { Controller, Get } from '@nestjs/common';
import { DashboardService } from './Dashboard.service';
@ApiTags('dashboard')
@Controller('dashboard')

View File

@@ -29,8 +29,6 @@ export class DashboardService {
/**
* Retrieve dashboard meta.
* @param {number} tenantId
* @param {number} authorizedUser
*/
public getBootMeta = async (): Promise<IDashboardBootMeta> => {
// Retrieves all orgnaization abilities.
@@ -60,17 +58,19 @@ export class DashboardService {
/**
* Retrieve the boot abilities.
* @returns
* @returns {Promise<IRoleAbility[]>}
*/
private getBootAbilities = async (): Promise<IRoleAbility[]> => {
const authorizedUser = await this.tenancyContext.getSystemUser();
const tenantUser = await this.tenantUserModel().query()
const tenantUser = await this.tenantUserModel()
.query()
.findOne('systemUserId', authorizedUser.id)
.withGraphFetched('role.permissions');
.withGraphFetched('role.permissions')
.throwIfNotFound();
return tenantUser.role.slug === 'admin'
? [{ subject: 'all', action: 'manage' }]
? [{ subject: 'all', ability: 'manage' }]
: this.transformRoleAbility(tenantUser.role.permissions);
};
}