translations and login page (#5008)

# Description of Changes

<!--
Please provide a summary of the changes, including:

- What was changed
- Why the change was made
- Any challenges encountered

Closes #(issue_number)
-->

---

## Checklist

### General

- [ ] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md)
(if applicable)
- [ ] I have performed a self-review of my own code
- [ ] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### Translations (if applicable)

- [ ] I ran
[`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing)
for more details.
This commit is contained in:
Anthony Stirling
2025-11-25 16:39:21 +00:00
committed by GitHub
parent 9a1f89486d
commit 7253b9fa6d
43 changed files with 32299 additions and 2979 deletions

View File

@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { Text, Stack, Alert } from '@mantine/core';
import { springAuth } from '@app/auth/springAuthClient';
import { useAuth } from '@app/auth/UseSession';
import { useTranslation } from 'react-i18next';
@@ -29,6 +30,8 @@ export default function Login() {
const [enabledProviders, setEnabledProviders] = useState<string[]>([]);
const [hasSSOProviders, setHasSSOProviders] = useState(false);
const [_enableLogin, setEnableLogin] = useState<boolean | null>(null);
const [isFirstTimeSetup, setIsFirstTimeSetup] = useState(false);
const [showDefaultCredentials, setShowDefaultCredentials] = useState(false);
// Redirect immediately if user has valid session (JWT already validated by AuthProvider)
useEffect(() => {
@@ -55,6 +58,10 @@ export default function Login() {
setEnableLogin(data.enableLogin ?? true);
// Set first-time setup flags
setIsFirstTimeSetup(data.firstTimeSetup ?? false);
setShowDefaultCredentials(data.showDefaultCredentials ?? false);
// Extract provider IDs from the providerList map
// The keys are like "/oauth2/authorization/google" - extract the last part
const providerIds = Object.keys(data.providerList || {})
@@ -259,6 +266,31 @@ export default function Login() {
</div>
)}
{/* Help section - only show on first-time setup with default credentials */}
{isFirstTimeSetup && showDefaultCredentials && (
<Alert
color="blue"
variant="light"
radius="md"
mt="xl"
>
<Stack gap="xs" align="center">
<Text size="sm" fw={600} ta="center">
{t('login.defaultCredentials', 'Default Login Credentials')}
</Text>
<Text size="sm" ta="center">
<Text component="span" fw={600}>{t('login.username', 'Username')}:</Text> admin
</Text>
<Text size="sm" ta="center">
<Text component="span" fw={600}>{t('login.password', 'Password')}:</Text> stirling
</Text>
<Text size="xs" c="dimmed" ta="center" mt="xs">
{t('login.changePasswordWarning', 'Please change your password after logging in for the first time')}
</Text>
</Stack>
</Alert>
)}
</AuthLayout>
);
}