@@ -66,11 +66,13 @@ class ConsentRequest extends AuthRequest {
6666 static async get ( req , res ) {
6767 const request = ConsentRequest . fromParams ( req , res )
6868
69- const appOrigin = request . getAppOrigin ( )
69+ const appUrl = request . getAppUrl ( )
70+ const appOrigin = `${ appUrl . protocol } //${ appUrl . host } `
71+ const serverUrl = url . parse ( req . app . locals . ldp . serverUri )
7072 // Check if is already registered or is data browser
7173 if ( request . isUserLoggedIn ( ) ) {
7274 if (
73- appOrigin === req . app . locals . ldp . serverUri ||
75+ ( appUrl && appUrl . host . includes ( serverUrl . host ) && appUrl . protocol === serverUrl . protocol ) ||
7476 await request . isAppRegistered ( req . app . locals . ldp , appOrigin , request . session . subject . _id )
7577 ) {
7678 request . setUserConsent ( appOrigin )
@@ -101,7 +103,8 @@ class ConsentRequest extends AuthRequest {
101103 let request = ConsentRequest . fromParams ( req , res )
102104
103105 if ( request . isUserLoggedIn ( ) ) {
104- const appOrigin = request . getAppOrigin ( )
106+ const appUrl = request . getAppUrl ( )
107+ const appOrigin = `${ appUrl . protocol } //${ appUrl . host } `
105108 debug ( 'Providing consent for app sharing' )
106109
107110 if ( consented ) {
@@ -133,9 +136,8 @@ class ConsentRequest extends AuthRequest {
133136 return true
134137 }
135138
136- getAppOrigin ( ) {
137- const parsed = url . parse ( this . authQueryParams . redirect_uri )
138- return `${ parsed . protocol } //${ parsed . host } `
139+ getAppUrl ( ) {
140+ return url . parse ( this . authQueryParams . redirect_uri )
139141 }
140142
141143 async getProfileGraph ( ldp , webId ) {
0 commit comments