Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(frontend:auth): handle impersonation logout without token refresh retry and force fallback logout on error

johavenead2508a4932
diff --git a/frontend/src/app/auth/auth.interceptor.ts b/frontend/src/app/auth/auth.interceptor.ts
index 8a3922b2..7f9c8132 100644
--- a/frontend/src/app/auth/auth.interceptor.ts
+++ b/frontend/src/app/auth/auth.interceptor.ts
@@ -6,6 +6,7 @@ import { catchError, filter, finalize, switchMap, take } from 'rxjs/operators'
import { SERVER_CONNECTION_ERROR } from '../app.constants'
import { hasReservedUrlChars } from '../common/utils/functions'
import { AuthService } from './auth.service'
+import { API_ADMIN_IMPERSONATE_LOGOUT } from '@sync-in-server/backend/src/applications/users/constants/routes'
@Injectable({
providedIn: 'root'
@@ -41,7 +42,7 @@ export class AuthInterceptor implements HttpInterceptor {
this.auth = this.injector.get(AuthService)
}
console.debug('AuthInterceptor:', request.url, error.status)
- if ([API_AUTH_REFRESH, API_AUTH_LOGIN, API_AUTH_LOGOUT].indexOf(request.url) === -1) {
+ if ([API_AUTH_REFRESH, API_AUTH_LOGIN, API_AUTH_LOGOUT, API_ADMIN_IMPERSONATE_LOGOUT].indexOf(request.url) === -1) {
if (this.isRefreshingToken) {
console.debug('AuthInterceptor: wait for refresh token')
return this.waitForRefreshToken.pipe(
diff --git a/frontend/src/app/auth/auth.service.ts b/frontend/src/app/auth/auth.service.ts
index cf8b1354..c93eb8b5 100644
--- a/frontend/src/app/auth/auth.service.ts
+++ b/frontend/src/app/auth/auth.service.ts
@@ -227,7 +227,8 @@ export class AuthService {
},
error: (e: HttpErrorResponse) => {
console.error(e)
- this.layout.sendNotification('error', 'Impersonate identity', 'logout', e)
+ this.store.userImpersonate.set(false)
+ this.logout(true, true)
}
})
}