Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add redirect for safe mode #14

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading