11using api . core . data . entities ;
22using api . core . Data ;
3+ using api . core . Data . Entities ;
34using api . core . Data . Enums ;
45using api . core . Data . Exceptions ;
56using api . core . Data . requests ;
@@ -26,15 +27,13 @@ namespace api.core.controllers;
2627/// for this to work.
2728/// </summary>
2829/// <param name="userService">Used to fetch and manage the organizers</param>
29- /// <param name="authService">Used to create a new user in the Supabase database</param>
3030/// <param name="emailService">Used to send an email to the newly created organizer</param>
3131/// <param name="configuration">Used to fetch the FRONTEND_BASE_URL from the environments variables</param>
3232[ Authorize ( Policy = AuthPolicies . IsModerator ) ]
3333[ ApiController ]
3434[ Route ( "api/organizers" ) ]
3535public class ModeratorUserController (
3636 IUserService userService ,
37- IAuthService authService ,
3837 IEmailService emailService ,
3938 IConfiguration configuration ) : ControllerBase
4039{
@@ -49,15 +48,15 @@ public class ModeratorUserController(
4948 /// <exception cref="NotFoundException{Organizer}"></exception>
5049 [ AllowAnonymous ]
5150 [ HttpGet ( "{organizerId}" ) ]
52- public IActionResult GetOrganizer ( Guid organizerId )
51+ public IActionResult GetOrganizer ( string organizerId )
5352 {
5453 var user = userService . GetUser ( organizerId ) ;
5554 return user . Type == "Organizer" ?
5655 Ok ( new Response < UserResponseDTO >
5756 {
5857 Data = user
5958 } )
60- : throw new NotFoundException < Organizer > ( ) ;
59+ : throw new NotFoundException < User > ( ) ;
6160 }
6261
6362 /// <summary>
@@ -68,32 +67,32 @@ public IActionResult GetOrganizer(Guid organizerId)
6867 /// <param name="organizer"></param>
6968 /// <returns></returns>
7069 /// <exception cref="ArgumentNullException"></exception>
71- [ HttpPost ]
72- public async Task < IActionResult > CreateOrganizer ( [ FromBody ] UserCreateDTO organizer )
73- {
74- var strongPassword = GenerateRandomPassword ( 12 ) ;
75- var supabaseUser = authService . SignUp ( organizer . Email , strongPassword ) ;
76- _ = Guid . TryParse ( supabaseUser , out Guid userId ) ;
77- var created = userService . AddOrganizer ( userId , organizer ) ;
78- var frontBaseUrl = configuration . GetValue < string > ( "FRONTEND_BASE_URL" ) ?? throw new ArgumentNullException ( "FRONTEND_BASE_URL is not set" ) ;
79- await emailService . SendEmailAsync (
80- organizer . Email ,
81- "Votre compte Hello!" ,
82- new UserCreationModel
83- {
84- Title = "Création de votre compte Hello!" ,
85- Salutation = $ "Bonjour { organizer . Organization } ,",
86- AccountCreatedText = "Votre compte Hello a été créé!" ,
87- TemporaryPasswordHeader = "Votre mot de passe temporaire est: " ,
88- TemporaryPassword = strongPassword ,
89- LoginButtonText = "Se connecter" ,
90- ButtonLink = new Uri ( $ "{ frontBaseUrl } /fr/login")
91- } ,
92- emails . EmailsUtils . UserCreationTemplate
93- ) ;
94-
95- return Ok ( new Response < UserResponseDTO > { Data = created } ) ;
96- }
70+ // [HttpPost]
71+ // public async Task<IActionResult> CreateOrganizer([FromBody] UserCreateDTO organizer)
72+ // {
73+ // var strongPassword = GenerateRandomPassword(12);
74+ // var supabaseUser = authService.SignUp(organizer.Email, strongPassword);
75+ // _ = Guid.TryParse(supabaseUser, out Guid userId);
76+ // var created = userService.AddOrganizer(userId, organizer);
77+ // var frontBaseUrl = configuration.GetValue<string>("FRONTEND_BASE_URL") ?? throw new ArgumentNullException("FRONTEND_BASE_URL is not set");
78+ // await emailService.SendEmailAsync(
79+ // organizer.Email,
80+ // "Votre compte Hello!",
81+ // new UserCreationModel
82+ // {
83+ // Title = "Création de votre compte Hello!",
84+ // Salutation = $"Bonjour {organizer.Organization},",
85+ // AccountCreatedText = "Votre compte Hello a été créé!",
86+ // TemporaryPasswordHeader = "Votre mot de passe temporaire est: ",
87+ // TemporaryPassword = strongPassword,
88+ // LoginButtonText = "Se connecter",
89+ // ButtonLink = new Uri($"{frontBaseUrl}/fr/login")
90+ // },
91+ // emails.EmailsUtils.UserCreationTemplate
92+ // );
93+
94+ // return Ok(new Response<UserResponseDTO> { Data = created });
95+ // }
9796
9897 /// <summary>
9998 /// Get all users with pagination and search term
@@ -131,7 +130,7 @@ public IActionResult GetUsers(string? search, OrganizerAccountActiveFilter filte
131130 /// <param name="reason">pass a reason for the toggle active change, will be send by email</param>
132131 /// <returns></returns>
133132 [ HttpPatch ( "{organizerId}/toggle" ) ]
134- public async Task < IActionResult > ToggleOrganizer ( Guid organizerId , [ FromQuery ] string ? reason )
133+ public async Task < IActionResult > ToggleOrganizer ( string organizerId , [ FromQuery ] string ? reason )
135134 {
136135 var success = userService . ToggleUserActiveState ( organizerId ) ;
137136 var organizer = userService . GetUser ( organizerId ) ;
0 commit comments