feat: admin can create users manually + disable registration (#85)
Backend:
- POST /api/admin/users — admin-only user creation endpoint
- username & password required, email optional (auto-generated placeholder)
- role, quota_bytes, active all configurable
- creates personal folder automatically
- PUT /api/admin/users/{id}/password — admin password reset
- GET/PUT /api/admin/settings/registration — toggle public registration
- Supports env var OXICLOUD_DISABLE_REGISTRATION override
- Blocks POST /api/auth/register when disabled
- AdminCreateUserDto, AdminResetPasswordDto added to settings DTOs
- registration_enabled field added to DashboardStatsDto
Frontend (admin.html):
- 'Create User' button in Users tab with full modal form
(username, password, email, role, quota)
- 'Reset Password' button per user in actions column
- 'Allow public self-registration' toggle in Dashboard > System
with warning banner when disabled
Closes #85
This commit is contained in:
@@ -80,6 +80,27 @@ pub struct UpdateUserQuotaDto {
|
||||
pub quota_bytes: i64,
|
||||
}
|
||||
|
||||
/// Request body for admin-created users
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct AdminCreateUserDto {
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
/// Optional — if omitted, a placeholder email is generated
|
||||
pub email: Option<String>,
|
||||
/// "admin" or "user"; defaults to "user"
|
||||
pub role: Option<String>,
|
||||
/// Storage quota in bytes; 0 = unlimited. If omitted, uses role default.
|
||||
pub quota_bytes: Option<i64>,
|
||||
/// Whether the account is active; defaults to true
|
||||
pub active: Option<bool>,
|
||||
}
|
||||
|
||||
/// Request body for admin password reset
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct AdminResetPasswordDto {
|
||||
pub new_password: String,
|
||||
}
|
||||
|
||||
/// Query parameters for listing users
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ListUsersQueryDto {
|
||||
@@ -105,4 +126,5 @@ pub struct DashboardStatsDto {
|
||||
pub storage_usage_percent: f64,
|
||||
pub users_over_80_percent: i64,
|
||||
pub users_over_quota: i64,
|
||||
pub registration_enabled: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user