Commit graph

33 commits

Author SHA1 Message Date
Jiří Vrabec
602496ec08 Add user profile endpoints 2025-08-11 22:08:13 +02:00
Jiří Vrabec
84e16d655d Add exception messages 2025-08-11 20:07:31 +02:00
Jiří Vrabec
1b54a6d6a6 Merge branch '250809_UserProfile' of git.chillplace.beer:chilldev/drinkrate into 250809_UserProfile 2025-08-11 19:34:53 +02:00
Jiří Vrabec
4216535016 Prevent deleted user authentication 2025-08-11 19:33:55 +02:00
1dc37d3282 Handle not found user profile gracefully
Changes from throwing an exception when a user profile is not found to returning null.

This prevents the application from crashing when a user profile is not found, allowing for more graceful error handling.
2025-08-11 18:46:35 +02:00
7bf7f23925 Add exception handling middleware
Implement global exception handling to provide consistent error responses.
Registes custom exceptions with corresponding HTTP status codes and descriptions.
2025-08-11 18:36:12 +02:00
1906d0de0d Remove explicit fail call in admin authorization 2025-08-11 18:18:31 +02:00
Jiří Vrabec
ae723cecaf Add more exceptions 2025-08-11 07:56:11 +02:00
Jiří Vrabec
8058add053 Rename class 2025-08-11 07:46:14 +02:00
Martin Velebil
a246764e44 Movesadmin status update endpoint
Relocates the endpoint for updating user admin status from the dedicated AdminController to the UserProfileController.

This consolidates user profile management under a single controller
and leverages existing authorization policies.
2025-08-10 18:33:36 +02:00
Martin Velebil
3230a5ed0f Merge remote-tracking branch 'origin/250809_UserProfile' into 250810_UserProfileAdmin
# Conflicts:
#	DrinkRateAPI/Services/UserProfileService.cs
2025-08-10 18:18:06 +02:00
b59fef222f Implement admin-only authorization policy
Adds an authorization policy to restrict access to admin-only endpoints.
Creates an `AdminOnlyRequirement` and `AdminOnlyHandler` to check if a user has admin privileges.
Applies the "AdminOnly" policy to the AdminController to secure admin functionalities.
Modifies the endpoint for changing user admin status to include the user ID in the route.
2025-08-10 18:07:34 +02:00
Jiří Vrabec
dad144a80f Create user profile service base 2025-08-10 16:35:36 +02:00
b2b8d1e076 Refactor admin endpoint and logic
Moves the ChangeUserAdminStatusRequest to the ApiModels folder.
Updates the admin controller route to "admin" and the admin status
endpoint to "adminStatus".
Makes the ChangeUserAdminStatus method asynchronous.
Uses NotFoundException instead of KeyNotFoundException.
2025-08-10 16:23:35 +02:00
c0860b05d1 Enable admin status management
Adds functionality to allow administrators to modify the admin status of other users.

Introduces an endpoint for changing user admin status, accessible only to existing administrators.
This change includes necessary services and request models to handle the logic.
2025-08-10 13:55:20 +02:00
Jiří Vrabec
76cb56d819 Add user authorization service 2025-08-10 11:20:18 +02:00
Jiří Vrabec
703d4751e2 Add EF object history 2025-08-09 19:05:02 +02:00
e06700458f Create default user profile on registration
Implement a `UserWithProfileManager` to automatically create a default user profile upon user registration.
This ensures that each user has an associated profile with default values (e.g., `UserName`, `IsAdmin`, `IsDeleted`).
Updates the database schema to reflect the change from UserId to UserProfileId in the UserProfileCompanyTableStat and UserProfileProductTableStat entities.
2025-08-09 18:54:27 +02:00
e7ce2c7718 Fix forgotten renaming of user, change applicationuser id type to guid 2025-08-09 17:57:41 +02:00
d2e156b9f1 Fix identityuser being used instead of DbApplicationUser 2025-08-09 17:05:55 +02:00
bdb3475685 Rename migration to init 2025-08-09 16:14:04 +02:00
9892337644 Merge IdentityDbContext into ApplicationDbContext 2025-08-09 16:09:37 +02:00
786f83bf2d Connect UserProfile with ApplicationUser
Establishes a link between DbUserProfile and DbApplicationUser,
allowing for better management of user-related information
and integration with ASP.NET Identity.

Renames DbUser to DbUserProfile and updates related entities and configurations.
2025-08-09 15:43:32 +02:00
Jiří Vrabec
e6ed0d1b37 Create base db migration 2025-08-09 14:54:45 +02:00
0a4c4abcbc Merge branch 'EntityFrameworkSetup' into EntityFrameworkSetupPropertyMap
# Conflicts:
#	DrinkRateAPI/Contexts/ApplicationDbContext.cs
2025-08-09 14:08:30 +02:00
Jiří Vrabec
855e9a4bcf Map EF user and user stats 2025-08-09 14:06:56 +02:00
53df5dcdc1 Add Product and related entity mappings 2025-08-09 14:05:37 +02:00
aefaac9140 Change property name for consistency 2025-08-09 13:49:10 +02:00
Jiří Vrabec
10dd4c9b0d Map EF company table and table view 2025-08-09 13:10:58 +02:00
Jiří Vrabec
fe30203373 Remove useless files 2025-08-09 12:58:00 +02:00
Jiří Vrabec
2830d5dd48 Upgrade EF models and add some EF mappings 2025-08-09 12:54:29 +02:00
Jiří Vrabec
b7996872cb Add EF objects 2025-08-09 01:00:49 +02:00
Jiří Vrabec
6c5a4bfb26 INIT 2025-08-08 23:28:03 +02:00