diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs index 7977f6a..964bcc6 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InvoiceController.cs @@ -44,12 +44,15 @@ public class InvoiceController : Controller { #region API Methods [HttpGet] - public async Task>> Get(bool? all = false) { + public ActionResult> Get(bool? all = false) { IList roles; string id; try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver. - var user = await _userMan.GetUserAsync(_signInMan.Context.User); - roles = await _userMan.GetRolesAsync(user); + var user = _userMan.GetUserAsync(_signInMan.Context.User); + user.Wait(); + var rolecall = _userMan.GetRolesAsync(user.Result); + rolecall.Wait(); + roles = rolecall.Result; } catch (Exception e) { _logger.LogError(10, e.Message); roles = new List(); @@ -59,17 +62,17 @@ public class InvoiceController : Controller { id = _signInMan.Context.User.Identity.GetUserId(); if (all is not null && all == true && roles.Contains("Administrateur")) return Ok(_context.Invoices - .Include("ShippingAddress") + .Include(x => x.ShippingAddress) + .Include(x => x.LinkedAccount) .Include(x => x.Products) .ThenInclude(y => y.Product) .ToList()); - - else - return Ok(_context.Invoices - .Include("ShippingAddress") - .Include(x => x.Products) - .ThenInclude(y => y.Product) - .Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList()); + else return Ok(_context.Invoices + .Include(x => x.ShippingAddress) + .Include(x => x.LinkedAccount) + .Include(x => x.Products) + .ThenInclude(y => y.Product) + .Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList()); } catch (Exception e) { _logger.LogError(10, e.Message); return BadRequest(); diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs index c2e4632..5e051d2 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/UserController.cs @@ -71,7 +71,8 @@ public class UserController : Controller { } try { - usr.PasswordHash = new PasswordHasher().HashPassword(usr, sign.Password); + var pas = new PasswordHasher().HashPassword(usr, sign.Password); + usr.PasswordHash = pas; } catch (Exception e){ return BadRequest($"Erreur de mot de passe: {e.Message}"); }