Skip to content

Commit ebc4a96

Browse files
Fix lint issues
1 parent 9af1c16 commit ebc4a96

File tree

4 files changed

+27
-28
lines changed

4 files changed

+27
-28
lines changed

src/auth/ekirjastoFetch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export async function fetchEAuthToken(
1717

1818
//If in some case, the bearer text is present, remove it so there is no repetition in the request
1919
if (token?.startsWith("Bearer ")) {
20-
token = token.replace("Bearer ", "")
21-
console.log(token)
20+
token = token.replace("Bearer ", "");
2221
}
2322

2423
const response = await fetchWithHeaders(url, `Bearer ${token}`, {}, "POST");
@@ -44,7 +43,7 @@ export async function fetchEkirjastoToken(
4443

4544
const response = await fetchWithHeaders(url, token, {}, "GET");
4645
const json = await response.json();
47-
46+
4847
if (!response.ok) {
4948
throw new ServerError(url, response.status, json);
5049
}

src/auth/useCredentials.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ function getCredentialsCookie(
113113
if (librarySlug === "ekirjasto") {
114114
// Get access token, for ekirjasto login credentials
115115
const accessToken = Cookie.get(cookieNameEkirjasto());
116-
if(!accessToken) {
117-
console.log("No access token")
118-
return undefined
116+
if (!accessToken) {
117+
console.log("No access token");
118+
return undefined;
119119
}
120120
// Create ekirjasto authentication credentials
121121
const authCredentials: AuthCredentials = {

src/components/context/UserContext.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,16 @@ export const UserProvider = ({ children }: UserProviderProps) => {
121121
}
122122
}
123123
);
124-
124+
125125
async function getEkirjastoToken(
126126
token: string,
127127
fetchUrl: string | undefined
128-
) : Promise<string> {
129-
const { token : ekirjastoToken} = await fetchEkirjastoToken(fetchUrl, token)
130-
return ekirjastoToken
128+
): Promise<string> {
129+
const { token: ekirjastoToken } = await fetchEkirjastoToken(
130+
fetchUrl,
131+
token
132+
);
133+
return ekirjastoToken;
131134
}
132135

133136
function signIn(

src/pages/[library]/magazines/index.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,38 @@ import withAppProps, { AppProps } from "dataflow/withAppProps";
1010
import useUser from "components/context/UserContext";
1111
import useLogin from "auth/useLogin";
1212
import useLibraryContext from "components/context/LibraryContext";
13-
import useCredentials from "auth/useCredentials";
1413
import {
1514
getMagazineReaderUrl,
1615
getMagazineAllowedOrigin,
1716
MAGAZINE_CONFIG
1817
} from "config/magazines";
1918
import Head from "next/head";
2019
import BreadcrumbBar from "components/BreadcrumbBar";
21-
import { EkirjastoAuthType } from "types/opds1";
2220
import { EKIRJASTO_AUTH_TYPE } from "utils/constants";
2321

2422
const MagazinesFixedContent: React.FC = () => {
2523
const iframeRef = React.useRef<HTMLIFrameElement | null>(null);
26-
const { token, signIn, getEkirjastoToken } = useUser();
24+
const { token, getEkirjastoToken } = useUser();
2725
const { initLogin } = useLogin();
2826
const { slug, authMethods } = useLibraryContext();
29-
const { credentials, setCredentials, clearCredentials } = useCredentials(
30-
slug,
31-
authMethods
32-
);
33-
const ekirMethod = authMethods.find(method => method.type === EKIRJASTO_AUTH_TYPE)
34-
let ekirjastoToken: string | undefined
27+
const ekirMethod = authMethods.find(
28+
method => method.type === EKIRJASTO_AUTH_TYPE
29+
);
30+
let ekirjastoToken: string | undefined;
3531
if (ekirMethod && token) {
3632
try {
37-
//Get the ekirjastoToken
38-
const ekirjastoTokenUrl = ekirMethod.links.find(link => link.rel === "ekirjasto_token")?.href
39-
ekirjastoToken = getEkirjastoToken(token, ekirjastoTokenUrl)
33+
//Get the ekirjastoToken
34+
const ekirjastoTokenUrl = ekirMethod.links.find(
35+
link => link.rel === "ekirjasto_token"
36+
)?.href;
37+
ekirjastoToken = getEkirjastoToken(token, ekirjastoTokenUrl);
4038
} catch (error) {
4139
//Can not start the reader so should show not logged in or something
4240
}
4341
}
4442
if (!token) {
45-
console.log("There is no token so should be logged out")
46-
ekirjastoToken = undefined
43+
console.log("There is no token so should be logged out");
44+
ekirjastoToken = undefined;
4745
}
4846

4947
const storageKey = React.useMemo(
@@ -69,10 +67,9 @@ const MagazinesFixedContent: React.FC = () => {
6967
const allowedOrigin = getMagazineAllowedOrigin();
7068

7169
if (!token) {
72-
console.log("No token!")
73-
70+
console.log("No token!");
7471
}
75-
72+
7673
if (e.origin !== allowedOrigin || typeof e.data !== "string") return;
7774

7875
if (e.data === "ewl:unauthorized") {
@@ -100,7 +97,7 @@ const MagazinesFixedContent: React.FC = () => {
10097
});
10198
}
10299
},
103-
[initLogin, ekirjastoToken, storageKey]
100+
[initLogin, ekirjastoToken, token, storageKey]
104101
);
105102

106103
React.useEffect(() => {

0 commit comments

Comments
 (0)