User accounts provide secure access to the GoMFT application with role-based permissions
}
// User listing component
templ userList(users []db.User) {
for _, user := range users {
@UserDialog(
fmt.Sprintf("delete-user-dialog-%d", user.ID),
"Delete User",
fmt.Sprintf("Are you sure you want to delete user \"%s\"? This action cannot be undone.", user.Email),
"bg-red-600 hover:bg-red-700 dark:bg-red-600 dark:hover:bg-red-700",
"Delete User",
"delete",
user.ID,
user.Email,
)
}
Email
Role
Status
Actions
if len(users) == 0 {
No users found. Click the "Add User" button to create your first user.
} else {
for _, user := range users {
{ user.Email }
if user.GetIsAdmin() {
Admin
} else {
User
}
if user.GetAccountLocked() {
Locked
} else {
Active
}
}
}
}
// User form component for creating/editing users
templ userForm(user *db.User, isNew bool, availableRoles []db.Role) {
if isNew {
Create New User
} else {
Edit User: { user.Email }
}
if isNew {
Create a new user account with appropriate permissions.
} else {
Update user information and permissions.
}
}
// Helper function to check if a user has a specific role
func hasRole(user *db.User, roleID uint) bool {
for _, role := range user.Roles {
if role.ID == roleID {
return true
}
}
return false
}
// UserDialog for confirmation actions
templ UserDialog(id string, title string, message string, confirmClass string, confirmText string, action string, userID uint, userEmail string) {
if action == "delete" {
} else {
}
{ message }
}
script triggerUserDelete(dialogId string, userID uint, userEmail string) {
// Hide the dialog
document.getElementById(dialogId).classList.add("hidden");
document.getElementById(dialogId).classList.remove("flex");
// Store data in a way that's accessible to event handlers
window.lastDeletedUser = {
id: userID,
email: userEmail
};
// Add custom marker to track this deletion
window.currentlyDeletingUser = true;
}