File tree Expand file tree Collapse file tree 8 files changed +26
-16
lines changed
integrations/runtime/middlewares
webui/components/common/hooks
test/domain/tenant/fixtures Expand file tree Collapse file tree 8 files changed +26
-16
lines changed Original file line number Diff line number Diff line change 666666 "alwaysDisplayInConsole" : false ,
667667 "clientAuthenticatorType" : " client-secret" ,
668668 "redirectUris" : [
669- " http://a.comify.local:3000/rpc/domain/authentication/login" ,
670669 " http://localhost:3000/rpc/domain/authentication/login" ,
671670 " http://localhost:5173/rpc/domain/authentication/login"
672671 ],
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import getCreatorByEmail from '^/domain/creator/getByEmail';
55import registerCreator from '^/domain/creator/register' ;
66import { type Tenant } from '^/domain/tenant' ;
77
8- import type { Requester } from '../types' ;
8+ import { type Requester } from '../types' ;
99
1010export default async function login ( identity : Identity , tenant : Tenant ) : Promise < Requester >
1111{
Original file line number Diff line number Diff line change 22import type { ValidationSchema } from '^/integrations/validation' ;
33import validator from '^/integrations/validation' ;
44
5- import { optionalIdValidation } from '^/domain/definitions' ;
5+ import { optionalIdValidation , requiredIdValidation } from '^/domain/definitions' ;
66
77import InvalidCreator from '../InvalidCreator' ;
88import { fullNameValidation } from '../definitions' ;
@@ -19,7 +19,7 @@ const schema: ValidationSchema =
1919 required : true
2020 }
2121 } ,
22- tenantId : optionalIdValidation ,
22+ tenantId : requiredIdValidation ,
2323 portraitId : optionalIdValidation
2424} ;
2525
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import type { ValidationModel } from './types';
1010const schema : ValidationSchema =
1111{
1212 creatorId : requiredIdValidation ,
13- tenantId : optionalIdValidation ,
13+ tenantId : requiredIdValidation ,
1414 comicId : optionalIdValidation ,
1515 commentId : optionalIdValidation ,
1616 parentId : optionalIdValidation
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export default class OriginMiddleware implements Middleware
7575
7676 #validateOriginValue( value : string | undefined ) : void
7777 {
78- const result = validator . validate ( { url : value } , schema ) ;
78+ const result = validator . validate ( { origin : value } , schema ) ;
7979
8080 if ( result . invalid )
8181 {
Original file line number Diff line number Diff line change @@ -17,13 +17,25 @@ export default class RequesterMiddleware implements Middleware
1717 request . setHeader ( 'Authorization' , this . #authorization) ;
1818 }
1919
20- const response = await next ( ) ;
21-
22- if ( response . hasHeader ( 'Authorization' ) )
20+ try
2321 {
24- this . #authorization = response . getHeader ( 'Authorization' ) ! ;
22+ const response = await next ( ) ;
23+
24+ if ( response . hasHeader ( 'Authorization' ) )
25+ {
26+ this . #authorization = response . getHeader ( 'Authorization' ) ! ;
27+ }
28+
29+ return response ;
2530 }
31+ catch ( error )
32+ {
33+ if ( error ?. constructor ?. name === 'Unauthorized' )
34+ {
35+ this . #authorization = undefined ;
36+ }
2637
27- return response ;
38+ throw error ;
39+ }
2840 }
2941}
Original file line number Diff line number Diff line change 11
22import { useCallback } from 'react' ;
33
4+ import { tenant } from '^/domain/tenant' ;
45import getByOriginConverted from '^/domain/tenant/getByOriginConverted' ;
56
67import { useLoadData } from '^/webui/hooks' ;
@@ -9,9 +10,7 @@ export function useTenant()
910{
1011 const getTenant = useCallback ( async ( ) =>
1112 {
12- const tenant = await getByOriginConverted ( '' ) ;
13-
14- return tenant ;
13+ return await getByOriginConverted ( tenant . origin ) ;
1514
1615 } , [ ] ) ;
1716
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ export const VALUES =
55 TENANT1 : 'example.com'
66 } ,
77 ORIGINS : {
8- FIRST : 'alpha.example.com' ,
9- SECOND : 'beta.example.com' ,
8+ FIRST : 'http:// alpha.example.com' ,
9+ SECOND : 'http:// beta.example.com' ,
1010 UNKNOWN : 'unknown'
1111 }
1212} ;
You can’t perform that action at this time.
0 commit comments