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
|
.env
|
||||||
.venv/
|
.venv/
|
||||||
data/
|
data/
|
||||||
|
!data/branding/
|
||||||
|
!data/branding/**
|
||||||
backend/__pycache__/
|
backend/__pycache__/
|
||||||
**/__pycache__/
|
**/__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ COPY requirements.txt .
|
|||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
|
COPY data/branding /app/data/branding
|
||||||
|
|
||||||
EXPOSE 8000
|
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:
|
services:
|
||||||
backend:
|
backend:
|
||||||
build:
|
build:
|
||||||
context: ./backend
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: backend/Dockerfile
|
||||||
env_file:
|
env_file:
|
||||||
- ./.env
|
- ./.env
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ export default function UsersPage() {
|
|||||||
const [users, setUsers] = useState<AdminUser[]>([])
|
const [users, setUsers] = useState<AdminUser[]>([])
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [passwordInputs, setPasswordInputs] = useState<Record<string, string>>({})
|
|
||||||
const [passwordStatus, setPasswordStatus] = useState<Record<string, string>>({})
|
|
||||||
|
|
||||||
const loadUsers = async () => {
|
const loadUsers = async () => {
|
||||||
try {
|
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(() => {
|
useEffect(() => {
|
||||||
if (!getToken()) {
|
if (!getToken()) {
|
||||||
@@ -197,27 +159,6 @@ export default function UsersPage() {
|
|||||||
{user.isBlocked ? 'Allow access' : 'Block access'}
|
{user.isBlocked ? 'Allow access' : 'Block access'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user