mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
Add generateRandomString helper function and remove nanoid dependency
This commit is contained in:
@ -18,6 +18,7 @@ import {
|
||||
import { SpaceEntity } from '@app/common/modules/space/entities';
|
||||
import { UpdateUnitNameDto } from '../dtos/update.unit.dto';
|
||||
import { UserSpaceRepository } from '@app/common/modules/user-space/repositories';
|
||||
import { generateRandomString } from '@app/common/helper/randomString';
|
||||
|
||||
@Injectable()
|
||||
export class UnitService {
|
||||
@ -284,10 +285,8 @@ export class UnitService {
|
||||
}
|
||||
async getUnitInvitationCode(unitUuid: string): Promise<any> {
|
||||
try {
|
||||
const { nanoid } = await import('nanoid');
|
||||
|
||||
// Generate a 6-character random invitation code
|
||||
const invitationCode = nanoid(6);
|
||||
const invitationCode = generateRandomString(6);
|
||||
|
||||
// Update the unit with the new invitation code
|
||||
await this.spaceRepository.update({ uuid: unitUuid }, { invitationCode });
|
||||
@ -304,6 +303,8 @@ export class UnitService {
|
||||
type: updatedUnit.spaceType.type,
|
||||
};
|
||||
} catch (err) {
|
||||
console.log('err', err);
|
||||
|
||||
if (err instanceof BadRequestException) {
|
||||
throw err;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user