Skip to content

Commit

Permalink
usecase, feature: userpass-login: disable nodejs feature is userpass …
Browse files Browse the repository at this point in the history
…is disabled.
  • Loading branch information
maany committed Nov 26, 2024
1 parent 099ec19 commit c790558
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/lib/core/use-case/userpass-login-usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UserPassLoginInputPort from '../port/primary/userpass-login-input-port';
import type UserPassLoginOutputPort from '../port/primary/userpass-login-output-port';
import type AccountGatewayOutputPort from '../port/secondary/account-gateway-output-port';
import type AuthServerGatewayOutputPort from '../port/secondary/auth-server-gateway-output-port';
import type EnvConfigGatewayOutputPort from '../port/secondary/env-config-gateway-output-port';

/**
* UseCase for UserPassLogin workflow.
Expand All @@ -21,12 +22,23 @@ class UserPassLoginUseCase implements UserPassLoginInputPort {
private presenter: UserPassLoginOutputPort<any>,
private authServer: AuthServerGatewayOutputPort,
private rucioAccountGateway: AccountGatewayOutputPort,
private envConfigGateway: EnvConfigGatewayOutputPort,
) {
this.presenter = presenter;
this.authServer = authServer;
this.rucioAccountGateway = rucioAccountGateway;
this.envConfigGateway = envConfigGateway;
}
async execute(request: UserpassLoginRequest): Promise<void> {
const userpassLoginEnabled = await this.envConfigGateway.userpassEnabled();
if (!userpassLoginEnabled) {
const errorModel: UserpassLoginError = {
type: 'AUTH_SERVER_CONFIGURATION_ERROR',
message: 'Userpass login is not enabled',
};
await this.presenter.presentError(errorModel);
return;
}
const dto = await this.authServer.userpassLogin(request.username, request.password, request.account, request.vo);
let role: Role | undefined;
let country: string | undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/infrastructure/ioc/container-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ appContainer
(context: interfaces.Context) => (session: IronSession, response: NextApiResponse) => {
const rucioAuthServer: AuthServerGatewayOutputPort = appContainer.get(GATEWAYS.AUTH_SERVER);
const rucioAccountGateway: AccountGatewayOutputPort = appContainer.get(GATEWAYS.ACCOUNT);
return new UserPassLoginUseCase(new UserPassLoginPresenter(session, response), rucioAuthServer, rucioAccountGateway);
const envConfigGateway: EnvConfigGatewayOutputPort = appContainer.get(GATEWAYS.ENV_CONFIG);
return new UserPassLoginUseCase(new UserPassLoginPresenter(session, response), rucioAuthServer, rucioAccountGateway, envConfigGateway);
},
);

Expand Down

0 comments on commit c790558

Please sign in to comment.