mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: refactoring middlewares to typescript.
This commit is contained in:
@@ -3,7 +3,6 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { ServiceError } from '@/exceptions';
|
||||
import { IAccountDTO, IAccount } from '@/interfaces';
|
||||
import { difference } from 'lodash';
|
||||
import { tenant } from 'config/config';
|
||||
|
||||
@Service()
|
||||
export default class AccountsService {
|
||||
@@ -137,6 +136,7 @@ export default class AccountsService {
|
||||
public async newAccount(tenantId: number, accountDTO: IAccountDTO) {
|
||||
const { Account } = this.tenancy.models(tenantId);
|
||||
|
||||
// Validate the account code uniquiness.
|
||||
if (accountDTO.code) {
|
||||
await this.isAccountCodeUniqueOrThrowError(tenantId, accountDTO.code);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ export default class AuthenticationService {
|
||||
this.logger.info('[register] Someone trying to register.');
|
||||
await this.validateEmailAndPhoneUniqiness(registerDTO);
|
||||
|
||||
this.logger.info('[register] Creating a new tenant org.')
|
||||
this.logger.info('[register] Creating a new tenant organization.')
|
||||
const tenant = await this.newTenantOrganization();
|
||||
|
||||
this.logger.info('[register] Trying hashing the password.')
|
||||
|
||||
@@ -3,7 +3,6 @@ import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { SystemUser } from "@/system/models";
|
||||
import { ServiceError, ServiceErrors } from "@/exceptions";
|
||||
import { ISystemUser, ISystemUserDTO } from "@/interfaces";
|
||||
import { ISystemUser } from "src/interfaces";
|
||||
|
||||
@Service()
|
||||
export default class UsersService {
|
||||
@@ -20,9 +19,9 @@ export default class UsersService {
|
||||
async editUser(tenantId: number, userId: number, userDTO: ISystemUserDTO): Promise<ISystemUser> {
|
||||
const foundUsers = await SystemUser.query()
|
||||
.whereNot('id', userId)
|
||||
.andWhere((q) => {
|
||||
q.where('email', userDTO.email);
|
||||
q.orWhere('phone_number', userDTO.phoneNumber);
|
||||
.andWhere((query) => {
|
||||
query.where('email', userDTO.email);
|
||||
query.orWhere('phone_number', userDTO.phoneNumber);
|
||||
})
|
||||
.where('tenant_id', tenantId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user