Skip to content

Commit

Permalink
feat: add redirect for safe mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tomzemp committed Mar 15, 2024
1 parent e4eb623 commit 1e8444d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
11 changes: 9 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-03-13T14:28:23.404Z\n"
"PO-Revision-Date: 2024-03-13T14:28:23.404Z\n"
"POT-Creation-Date: 2024-03-14T15:15:04.384Z\n"
"PO-Revision-Date: 2024-03-14T15:15:04.384Z\n"

msgid "Please confirm that you are not a robot by checking the checkbox."
msgstr "Please confirm that you are not a robot by checking the checkbox."
Expand Down Expand Up @@ -195,3 +195,10 @@ msgstr "Choose new password"

msgid "Enter the new password for your account below"
msgstr "Enter the new password for your account below"

msgid ""
"You should shortly be redirected. If you are not redirected, please click "
"button."
msgstr ""
"You should shortly be redirected. If you are not redirected, please click "
"button."
2 changes: 2 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
CreateAccountPage,
PasswordResetRequestPage,
PasswordUpdatePage,
SafeModePage,
} from './pages/index.js'
import { LoginConfigProvider, useLoginConfig } from './providers/index.js'
import i18n from './locales/index.js' // eslint-disable-line
Expand All @@ -44,6 +45,7 @@ const LoginRoutes = () => {
path="/update-password"
element={<PasswordUpdatePage />}
/>
<Route path="/safeMode" element={<SafeModePage />} />
<Route path="*" element={<Navigate to="/" />} />
</Routes>
</>
Expand Down
1 change: 1 addition & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { default as CreateAccountPage } from './create-account.js'
export { default as LoginPage } from './login.js'
export { default as PasswordResetRequestPage } from './password-reset-request.js'
export { default as PasswordUpdatePage } from './password-update.js'
export { default as SafeModePage } from './safe-mode.js'
33 changes: 33 additions & 0 deletions src/pages/safe-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import i18n from '@dhis2/d2-i18n'
import { Button } from '@dhis2/ui'
import React, { useEffect } from 'react'
import { useLoginConfig } from '../providers/index.js'

const SAFE_MODE_ENDPOINT = 'dhis-web-commons/security/login.action'

const SafeModePage = () => {
const { baseUrl, uiLocale } = useLoginConfig()
const safeURL = `${baseUrl}/${SAFE_MODE_ENDPOINT}`

useEffect(() => {
window.location.href = `${baseUrl}/${SAFE_MODE_ENDPOINT}`
}, [baseUrl])

return (
<>
<p>
{i18n.t(
'You should shortly be redirected. If you are not redirected, please click redirect button.',
{ lng: uiLocale }
)}
</p>
<div>
<a rel="noopener noreferrer" href={safeURL}>
<Button>Redirect</Button>
</a>
</div>
</>
)
}

export default SafeModePage

0 comments on commit 1e8444d

Please sign in to comment.