1+ import { ErrorResponse } from 'oidc-client-ts'
12import { UserManager } from './userManager'
23import { PublicLinkManager } from './publicLinkManager'
34import {
@@ -44,6 +45,7 @@ export class AuthService implements AuthServiceInterface {
4445 private accessTokenExpiryThreshold = 10
4546
4647 public hasAuthErrorOccurred : boolean
48+ public lowAssuranceError : boolean
4749
4850 public initialize (
4951 configStore : ConfigStore ,
@@ -60,6 +62,7 @@ export class AuthService implements AuthServiceInterface {
6062 this . clientService = clientService
6163 this . router = router
6264 this . hasAuthErrorOccurred = false
65+ this . lowAssuranceError = false
6366 this . ability = ability
6467 this . language = language
6568 this . userStore = userStore
@@ -165,6 +168,10 @@ export class AuthService implements AuthServiceInterface {
165168 try {
166169 await this . userManager . updateContext ( user . access_token , fetchUserData )
167170 } catch ( e ) {
171+ if ( this . isLowAssuranceLevelError ( e ) ) {
172+ this . lowAssuranceError = true
173+ return
174+ }
168175 console . error ( e )
169176 await this . handleAuthError ( unref ( this . router . currentRoute ) )
170177 }
@@ -227,6 +234,10 @@ export class AuthService implements AuthServiceInterface {
227234 this . tokenTimerInitialized = true
228235 }
229236 } catch ( e ) {
237+ if ( this . isLowAssuranceLevelError ( e ) ) {
238+ this . lowAssuranceError = true
239+ return
240+ }
230241 console . error ( e )
231242 await this . handleAuthError ( unref ( this . router . currentRoute ) )
232243 }
@@ -269,6 +280,10 @@ export class AuthService implements AuthServiceInterface {
269280 ...( redirectRoute . query && { query : redirectRoute . query } )
270281 } )
271282 } catch ( e ) {
283+ if ( this . isLowAssuranceLevelError ( e ) ) {
284+ this . lowAssuranceError = true
285+ return this . router . push ( { name : 'accessDenied' , query : { reason : 'lowAssuranceLevel' } } )
286+ }
272287 console . warn ( 'error during authentication:' , e )
273288 return this . handleAuthError ( unref ( this . router . currentRoute ) )
274289 }
@@ -329,6 +344,10 @@ export class AuthService implements AuthServiceInterface {
329344 this . hasAuthErrorOccurred = true
330345 }
331346
347+ private isLowAssuranceLevelError ( e : unknown ) : boolean {
348+ return e instanceof ErrorResponse && e . error === 'low_assurance_level'
349+ }
350+
332351 public async resolvePublicLink (
333352 token : string ,
334353 passwordRequired : boolean ,
0 commit comments