2.0 KiB
2.0 KiB
HiveOps Management Portal - Memory
Admin Password Reset Feature
Successfully implemented admin password reset functionality for portal users.
Key Implementation Details
Backend Components:
AuditLog.java: Added USER_PASSWORD_RESET, USER_ENABLED, USER_DISABLED enum valuesAuditService.java: Added logPasswordReset(), logUserEnabled(), logUserDisabled() methodsUserRepository.java: Added search() method with JPQL query for email/name searchResetPasswordRequest.java: DTO with password validation (min 8, max 100 chars)UserService.java: Enhanced with findAll(), searchUsers(), resetPassword(), enableUser(), disableUser()PortalUserController.java: New controller at /portal/users with ADMIN role authorizationSecurityConfig.java: Added authorization rule for /portal/users/** requiring ADMIN role
Frontend Components:
list.html: User list with search, role filter, and paginationview.html: User details with action buttons (reset password, enable/disable)reset-password.html: Password reset form with validationbase.html: Added Users menu item in sidebar (ADMIN only)
Security Patterns
- BCrypt password encoding (strength 12)
- @PreAuthorize("hasRole('ADMIN')") on controller
- Prevents admin from disabling own account
- All actions logged to audit_logs table with admin email, target user email, and IP address
Common Patterns in Portal
- Flash messages via RedirectAttributes (success/error)
- getClientIp() helper extracts IP from X-Forwarded-For or remote address
- Pagination with PageRequest.of(page, size, Sort)
- Bootstrap 5 styling with badges for status/role
- Thymeleaf validation with .invalid-feedback for errors
Testing Checklist
- Login as admin@directlx.dev / admin123
- Navigate to Users menu (visible to ADMIN only)
- Search users by email/name
- View user details
- Reset password (validate min 8 chars, matching confirmation)
- Enable/disable user (cannot disable self)
- Verify audit log entries created
- Test login with new password