Browse Source

Remove auth application service

pull/2138/head
Hironsan 1 year ago
parent
commit
488fe8c6d8
5 changed files with 4 additions and 32 deletions
  1. 7
      frontend/domain/models/auth/authRepository.ts
  2. 3
      frontend/plugins/services.ts
  3. 3
      frontend/repositories/auth/apiAuthRepository.ts
  4. 17
      frontend/services/application/auth/authApplicationService.ts
  5. 6
      frontend/store/auth.js

7
frontend/domain/models/auth/authRepository.ts

@ -1,7 +0,0 @@
export interface AuthRepository {
login(username: string, password: string): Promise<void>
logout(): Promise<void>
socialLink(): Promise<any[]>
}

3
frontend/plugins/services.ts

@ -1,6 +1,5 @@
import { Plugin } from '@nuxt/types'
import { repositories } from './repositories'
import { AuthApplicationService } from '@/services/application/auth/authApplicationService'
import { ConfigApplicationService } from '@/services/application/autoLabeling/configApplicationService'
import { TemplateApplicationService } from '@/services/application/autoLabeling/templateApplicationService'
import { TaskStatusApplicationService } from '@/services/application/celery/taskStatusApplicationService'
@ -39,7 +38,6 @@ export interface Services {
option: OptionApplicationService
config: ConfigApplicationService
template: TemplateApplicationService
auth: AuthApplicationService
catalog: CatalogApplicationService
parse: ParseApplicationService
taskStatus: TaskStatusApplicationService
@ -76,7 +74,6 @@ const plugin: Plugin = (_, inject) => {
option: new OptionApplicationService(repositories.option),
config: new ConfigApplicationService(repositories.config),
template: new TemplateApplicationService(repositories.template),
auth: new AuthApplicationService(repositories.auth),
catalog: new CatalogApplicationService(repositories.catalog),
parse: new ParseApplicationService(repositories.parse),
taskStatus: new TaskStatusApplicationService(repositories.taskStatus),

3
frontend/repositories/auth/apiAuthRepository.ts

@ -1,7 +1,6 @@
import { AuthRepository } from '@/domain/models/auth/authRepository'
import ApiService from '@/services/api.service'
export class APIAuthRepository implements AuthRepository {
export class APIAuthRepository {
constructor(private readonly request = ApiService) {}
async login(username: string, password: string): Promise<void> {

17
frontend/services/application/auth/authApplicationService.ts

@ -1,17 +0,0 @@
import { AuthRepository } from '~/domain/models/auth/authRepository'
export class AuthApplicationService {
constructor(private readonly repository: AuthRepository) {}
public async login(username: string, password: string) {
await this.repository.login(username, password)
}
public async logout() {
await this.repository.logout()
}
public async socialLink() {
return await this.repository.socialLink()
}
}

6
frontend/store/auth.js

@ -41,14 +41,14 @@ export const getters = {
export const actions = {
async authenticateUser({ commit }, authData) {
try {
await this.$services.auth.login(authData.username, authData.password)
await this.$repositories.auth.login(authData.username, authData.password)
commit('setAuthenticated', true)
} catch (error) {
throw new Error('The credential is invalid')
}
},
async fetchSocialLink() {
return await this.$services.auth.socialLink()
return await this.$repositories.auth.socialLink()
},
async initAuth({ commit }) {
try {
@ -63,7 +63,7 @@ export const actions = {
}
},
async logout({ commit }) {
await this.$services.auth.logout()
await this.$repositories.auth.logout()
commit('setAuthenticated', false)
commit('setIsStaff', false)
commit('clearUsername')

Loading…
Cancel
Save