mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-14 08:39:07 +00:00
FEATURE: Reset and block users
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
|
||||
import { DucClient } from '../duc/client.config';
|
||||
import { Metadata } from '@grpc/grpc-js';
|
||||
import { UserActionRequest, UserActionResponse } from './dtos/login';
|
||||
|
||||
@Injectable()
|
||||
export class AuthClientService implements OnModuleInit {
|
||||
@@ -168,4 +169,70 @@ export class AuthClientService implements OnModuleInit {
|
||||
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
|
||||
);
|
||||
}
|
||||
|
||||
async blockUsers(userIds: string[], metadata: Metadata): Promise<UserActionResponse> {
|
||||
this.logger.info('blockUsers - Service starting', { userIds });
|
||||
|
||||
try {
|
||||
this.logger.debug('Calling BlockUser gRPC method', {
|
||||
request: { users: { userIds } },
|
||||
metadata: {
|
||||
access_token: metadata.get('access_token'),
|
||||
language: metadata.get('language')
|
||||
}
|
||||
});
|
||||
|
||||
const response = await lastValueFrom<UserActionResponse>(
|
||||
(this.authService as any).BlockUser({ users: { userIds } }, metadata),
|
||||
);
|
||||
|
||||
this.logger.info('blockUsers - Service success', { response });
|
||||
return response;
|
||||
} catch (error) {
|
||||
this.logger.error('blockUsers - Service error', {
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
request: { users: { userIds } }
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async unblockUsers(userIds: string[], metadata: Metadata): Promise<UserActionResponse> {
|
||||
this.logger.info('unblockUsers');
|
||||
return lastValueFrom(
|
||||
(this.authService as any).UnblockUser({ users: { userIds } }, metadata),
|
||||
);
|
||||
}
|
||||
|
||||
async resetUsers(userIds: string[], metadata: Metadata, defaultPassword: string): Promise<UserActionResponse> {
|
||||
this.logger.info('resetUsers');
|
||||
|
||||
try {
|
||||
this.logger.debug('Calling ResetUser gRPC method', {
|
||||
request: { users: { userIds }, defaultPassword },
|
||||
metadata: {
|
||||
access_token: metadata.get('access_token'),
|
||||
language: metadata.get('language')
|
||||
}
|
||||
});
|
||||
|
||||
const response = await lastValueFrom<UserActionResponse>(
|
||||
(this.authService as any).ResetUser({
|
||||
users: { userIds },
|
||||
defaultPassword
|
||||
}, metadata)
|
||||
);
|
||||
|
||||
this.logger.info('resetUsers - Success', { response });
|
||||
return response;
|
||||
} catch (error) {
|
||||
this.logger.error('resetUsers - Error', {
|
||||
error: error.message,
|
||||
stack: error.stack,
|
||||
request: { users: { userIds }, defaultPassword }
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user