Remove password fields from users page
This commit is contained in:
11
.dockerignore
Normal file
11
.dockerignore
Normal file
@@ -0,0 +1,11 @@
|
||||
.git
|
||||
.env
|
||||
*.log
|
||||
data/*
|
||||
!data/branding/
|
||||
!data/branding/**
|
||||
frontend/node_modules/
|
||||
frontend/.next/
|
||||
backend/__pycache__/
|
||||
**/__pycache__/
|
||||
**/*.pyc
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,8 @@
|
||||
.env
|
||||
.venv/
|
||||
data/
|
||||
!data/branding/
|
||||
!data/branding/**
|
||||
backend/__pycache__/
|
||||
**/__pycache__/
|
||||
*.pyc
|
||||
|
||||
@@ -9,6 +9,7 @@ COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app ./app
|
||||
COPY data/branding /app/data/branding
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
|
||||
BIN
data/branding/favicon.ico
Normal file
BIN
data/branding/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
data/branding/logo.png
Normal file
BIN
data/branding/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -1,8 +1,8 @@
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
dockerfile: backend/Dockerfile
|
||||
env_file:
|
||||
- ./.env
|
||||
ports:
|
||||
|
||||
@@ -25,8 +25,6 @@ export default function UsersPage() {
|
||||
const [users, setUsers] = useState<AdminUser[]>([])
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [passwordInputs, setPasswordInputs] = useState<Record<string, string>>({})
|
||||
const [passwordStatus, setPasswordStatus] = useState<Record<string, string>>({})
|
||||
|
||||
const loadUsers = async () => {
|
||||
try {
|
||||
@@ -105,42 +103,6 @@ export default function UsersPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const updateUserPassword = async (username: string) => {
|
||||
const newPassword = passwordInputs[username] || ''
|
||||
if (!newPassword || newPassword.length < 8) {
|
||||
setPasswordStatus((current) => ({
|
||||
...current,
|
||||
[username]: 'Password must be at least 8 characters.',
|
||||
}))
|
||||
return
|
||||
}
|
||||
try {
|
||||
const baseUrl = getApiBase()
|
||||
const response = await authFetch(
|
||||
`${baseUrl}/admin/users/${encodeURIComponent(username)}/password`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password: newPassword }),
|
||||
}
|
||||
)
|
||||
if (!response.ok) {
|
||||
const text = await response.text()
|
||||
throw new Error(text || 'Update failed')
|
||||
}
|
||||
setPasswordInputs((current) => ({ ...current, [username]: '' }))
|
||||
setPasswordStatus((current) => ({
|
||||
...current,
|
||||
[username]: 'Password updated.',
|
||||
}))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
setPasswordStatus((current) => ({
|
||||
...current,
|
||||
[username]: 'Could not update password.',
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!getToken()) {
|
||||
@@ -197,27 +159,6 @@ export default function UsersPage() {
|
||||
{user.isBlocked ? 'Allow access' : 'Block access'}
|
||||
</button>
|
||||
</div>
|
||||
{user.authProvider === 'local' && (
|
||||
<div className="user-actions">
|
||||
<input
|
||||
type="password"
|
||||
placeholder="New password (min 8 chars)"
|
||||
value={passwordInputs[user.username] || ''}
|
||||
onChange={(event) =>
|
||||
setPasswordInputs((current) => ({
|
||||
...current,
|
||||
[user.username]: event.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
<button type="button" onClick={() => updateUserPassword(user.username)}>
|
||||
Set password
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{passwordStatus[user.username] && (
|
||||
<div className="meta">{passwordStatus[user.username]}</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user