Le view invoices à l'air correct, et le password seeeeemble pu planter.

This commit is contained in:
MarcEricMartel 2022-11-14 07:32:48 -08:00
parent cdcc6b666d
commit 891d6b015d
2 changed files with 16 additions and 12 deletions

View File

@ -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,14 +62,14 @@ 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")
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());

View File

@ -71,7 +71,8 @@ public class UserController : Controller {
}
try {
usr.PasswordHash = new PasswordHasher<InventoryUser>().HashPassword(usr, sign.Password);
var pas = new PasswordHasher<InventoryUser>().HashPassword(usr, sign.Password);
usr.PasswordHash = pas;
} catch (Exception e){
return BadRequest($"Erreur de mot de passe: {e.Message}");
}