mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
refactor(nestjs): hook up auth endpoints
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user