diff --git a/argilla-frontend/v1/di/di.ts b/argilla-frontend/v1/di/di.ts index 5f0e575fdd..af262ad841 100644 --- a/argilla-frontend/v1/di/di.ts +++ b/argilla-frontend/v1/di/di.ts @@ -198,7 +198,7 @@ export const loadDependencyContainer = (context: Context) => { register(LoadUserUseCase).withDependencies(useAuth, UserRepository).build(), register(OAuthLoginUseCase) - .withDependencies(useAuth, OAuthRepository, LoadUserUseCase, useRoutes) + .withDependencies(useAuth, OAuthRepository, LoadUserUseCase) .build(), register(AuthLoginUseCase) diff --git a/argilla-frontend/v1/domain/usecases/oauth-login-use-case.ts b/argilla-frontend/v1/domain/usecases/oauth-login-use-case.ts index ef1aff1f36..445141984c 100644 --- a/argilla-frontend/v1/domain/usecases/oauth-login-use-case.ts +++ b/argilla-frontend/v1/domain/usecases/oauth-login-use-case.ts @@ -6,14 +6,12 @@ import { import { IAuthService } from "../services/IAuthService"; import { IOAuthRepository } from "../services/IOAuthRepository"; import { LoadUserUseCase } from "./load-user-use-case"; -import { RouterService } from "~/v1/domain/services/RouterService"; export class OAuthLoginUseCase { constructor( private readonly auth: IAuthService, private readonly oauthRepository: IOAuthRepository, - private readonly loadUser: LoadUserUseCase, - private readonly router: RouterService + private readonly loadUser: LoadUserUseCase ) {} async getProviders(): Promise { @@ -28,18 +26,6 @@ export class OAuthLoginUseCase { return this.oauthRepository.authorize(provider); } - redirect() { - let { redirect } = this.router.getQuery(); - if (Array.isArray(redirect)) { - redirect = redirect[0]; - } - - this.router.go(redirect || "/", { - external: false, - newWindow: false, - }); - } - async login(provider: ProviderType, oauthParams: OAuthParams) { await this.auth.logout(); @@ -49,8 +35,6 @@ export class OAuthLoginUseCase { await this.auth.setUserToken(token); await this.loadUser.execute(); - - this.redirect(); } } } diff --git a/argilla-frontend/v1/domain/usecases/oauth-login-usecase.test.ts b/argilla-frontend/v1/domain/usecases/oauth-login-usecase.test.ts index 0f520373bb..c10c2518fe 100644 --- a/argilla-frontend/v1/domain/usecases/oauth-login-usecase.test.ts +++ b/argilla-frontend/v1/domain/usecases/oauth-login-usecase.test.ts @@ -1,7 +1,6 @@ import { mock } from "@codescouts/test/jest"; import { IOAuthRepository } from "../services/IOAuthRepository"; import { IAuthService } from "../services/IAuthService"; -import { RouterService } from "../services/RouterService"; import { IUserRepository } from "../services/IUserRepository"; import { OAuthLoginUseCase } from "./oauth-login-use-case"; import { LoadUserUseCase } from "./load-user-use-case"; @@ -9,7 +8,6 @@ import { LoadUserUseCase } from "./load-user-use-case"; describe("OAuthLoginUseCase should", () => { test("logout user before call the login on backend", async () => { const auth = mock(); - const router = mock(); const oauthRepository = mock(); const loadUserUseCase = new LoadUserUseCase(auth, mock()); @@ -18,8 +16,7 @@ describe("OAuthLoginUseCase should", () => { const useCase = new OAuthLoginUseCase( auth, oauthRepository, - loadUserUseCase, - router + loadUserUseCase ); try { @@ -31,7 +28,6 @@ describe("OAuthLoginUseCase should", () => { test("call the backend after logout", async () => { const auth = mock(); - const router = mock(); const oauthRepository = mock(); const loadUserUseCase = new LoadUserUseCase(auth, mock()); @@ -39,8 +35,7 @@ describe("OAuthLoginUseCase should", () => { const useCase = new OAuthLoginUseCase( auth, oauthRepository, - loadUserUseCase, - router + loadUserUseCase ); await useCase.login("huggingface", null); @@ -50,19 +45,15 @@ describe("OAuthLoginUseCase should", () => { test("save token if the token is defined", async () => { const auth = mock(); - const router = mock(); const oauthRepository = mock(); const loadUserUseCase = new LoadUserUseCase(auth, mock()); - router.getQuery.mockReturnValue({}); - oauthRepository.login.mockResolvedValue("FAKE_TOKEN"); const useCase = new OAuthLoginUseCase( auth, oauthRepository, - loadUserUseCase, - router + loadUserUseCase ); await useCase.login("huggingface", null); @@ -72,7 +63,6 @@ describe("OAuthLoginUseCase should", () => { test("no save token if the token is not defined", async () => { const auth = mock(); - const router = mock(); const oauthRepository = mock(); const loadUserUseCase = new LoadUserUseCase(auth, mock()); @@ -81,8 +71,7 @@ describe("OAuthLoginUseCase should", () => { const useCase = new OAuthLoginUseCase( auth, oauthRepository, - loadUserUseCase, - router + loadUserUseCase ); await useCase.login("huggingface", null);