Le view invoices à l'air correct, et le password seeeeemble pu planter.
This commit is contained in:
		| @@ -44,12 +44,15 @@ public class InvoiceController : Controller { | ||||
|  | ||||
|     #region API Methods | ||||
|     [HttpGet] | ||||
|     public async Task<ActionResult<List<InvoiceModel>>> Get(bool? all = false) { | ||||
|     public ActionResult<List<InvoiceModel>> Get(bool? all = false) { | ||||
|         IList<string> 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<string>(); | ||||
| @@ -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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user