Skip to content

Commit

Permalink
fixed issues with authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
FaizanDurrani committed Nov 8, 2024
1 parent fedc382 commit 961ab84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/Paperback/Paperback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { BookDto, LibraryDto, PageBookDto, PageCollectionDto, PageDto, ReadProgr
// - getTags() which is called on the homepage
// - search method which is called even if the user search in an other source
export const PaperbackInfo: SourceInfo = {
version: '1.3',
version: '1.3.1',
name: 'Paperback',
icon: 'icon.png',
author: 'Lemon | Faizan Durrani',
Expand Down Expand Up @@ -100,18 +100,21 @@ export class KomgaRequestInterceptor implements SourceInterceptor {
// request.url = url
// return request
// }
if (request.headers === undefined) {
request.headers = {}
}
const headers = request.headers ?? {}

// We mustn't call this.getAuthorizationString() for the stateful submission request.
// This procedure indeed catchs the request used to check user credentials
// which can happen before an authorizationString is saved,
// raising an error in getAuthorizationString when we check for its existence
// Thus we only inject an authorizationString if none are defined in the request
if (request.headers.authorization === undefined) {
request.headers.authorization = await getAuthorizationString(this.stateManager)
if (headers.authorization === undefined) {
headers.authorization = await getAuthorizationString(this.stateManager)
}

// Paper's Note:
// Apparently setting a property on the `headers` object doesnt map over to swift
// we NEED to reset the base object for swift to realise its been changed
request.headers = headers
return request
}
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down

0 comments on commit 961ab84

Please sign in to comment.