Skip to content

Commit

Permalink
Merge pull request #248 from navikt/dev
Browse files Browse the repository at this point in the history
Prodsetting: 404 og autoRefresh
  • Loading branch information
stianStensli authored Aug 24, 2022
2 parents dc5620a + 4946d42 commit 608a204
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
25 changes: 4 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ env:
PRINT_PAYLOAD: true
CI: true
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Run tests
run: npm run test

test-build-and-push:
name: Test, build and push
runs-on: ubuntu-latest
Expand All @@ -35,10 +18,10 @@ jobs:
with:
node-version: 16
cache: npm
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Build application
run: npm run build
- name: Legg til build
run: mkdir ./build
- name: Legg til 404 fil
run: cp ./public/404_temp.html ./build/index.html
- name: Login to Docker
uses: docker/login-action@v1
with:
Expand Down
12 changes: 12 additions & 0 deletions public/404_temp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<meta charset="utf-8">
<title>404 oversikten</title>
</head>
<body>
Denne url'en er ikke lenger i bruk. </br>
Hvis du har denne url'en lagret som et bokmerke så må den endres.</br></br>
Ny url er:</br>
https://veilarbpersonflate.intern.nav.no/
</body>
</html>
7 changes: 7 additions & 0 deletions src/component/sesjon-notifikasjon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ export const SesjonNotifikasjon = (): React.ReactElement | null => {

useEffect(() => {
if (!expirationTimeMs) return;
const sixtyMin = 60 * 60 * 1000;
const fiveMin = 60 * 5 * 1000;
const oneMin = 60 * 1000;
const tenS = 10 * 1000;

const refreshTokenWorkAround = expirationTimeMs - sixtyMin;

const msTilUtloperSnartAlert = expirationTimeMs - fiveMin;
const msTilUtloggingAlert = expirationTimeMs - oneMin;
const msTilUtlogging = expirationTimeMs - tenS;

if(refreshTokenWorkAround < 0) {
window.location.href = loginUrl();
}

setUtlopAlertOmMs(Math.max(msTilUtloperSnartAlert, 0));
setUtloggingAlertOmMs(Math.max(msTilUtloggingAlert, 0));
setTvungenUtloggingOmMs(Math.max(msTilUtlogging, 0));
Expand Down
2 changes: 1 addition & 1 deletion src/mock/api/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const handlers = [
return res(ctx.delay(500), ctx.json({
loggedIn: true,
expirationTime: '2040-07-04T14:18:54.000Z',
remainingSeconds: 60 * 60
remainingSeconds: 60 * 70
}));
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/util/url-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export const loginUrl = () => {
if (erGCP()) {
return `${window.location.origin}/oauth2/login?redirect=${window.location.href}`;
}
return '/';
return `${window.location.href}`;
};

0 comments on commit 608a204

Please sign in to comment.