Le view invoices à l'air correct, et le password seeeeemble pu planter.
This commit is contained in:
parent
cdcc6b666d
commit
891d6b015d
@ -44,12 +44,15 @@ public class InvoiceController : Controller {
|
|||||||
|
|
||||||
#region API Methods
|
#region API Methods
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<List<InvoiceModel>>> Get(bool? all = false) {
|
public ActionResult<List<InvoiceModel>> Get(bool? all = false) {
|
||||||
IList<string> roles;
|
IList<string> roles;
|
||||||
string id;
|
string id;
|
||||||
try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver.
|
try { // Trouver les rôles de l'utilisateur, assumer non-admin si impossible à trouver.
|
||||||
var user = await _userMan.GetUserAsync(_signInMan.Context.User);
|
var user = _userMan.GetUserAsync(_signInMan.Context.User);
|
||||||
roles = await _userMan.GetRolesAsync(user);
|
user.Wait();
|
||||||
|
var rolecall = _userMan.GetRolesAsync(user.Result);
|
||||||
|
rolecall.Wait();
|
||||||
|
roles = rolecall.Result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_logger.LogError(10, e.Message);
|
_logger.LogError(10, e.Message);
|
||||||
roles = new List<string>();
|
roles = new List<string>();
|
||||||
@ -59,17 +62,17 @@ public class InvoiceController : Controller {
|
|||||||
id = _signInMan.Context.User.Identity.GetUserId();
|
id = _signInMan.Context.User.Identity.GetUserId();
|
||||||
if (all is not null && all == true && roles.Contains("Administrateur"))
|
if (all is not null && all == true && roles.Contains("Administrateur"))
|
||||||
return Ok(_context.Invoices
|
return Ok(_context.Invoices
|
||||||
.Include("ShippingAddress")
|
.Include(x => x.ShippingAddress)
|
||||||
|
.Include(x => x.LinkedAccount)
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(y => y.Product)
|
.ThenInclude(y => y.Product)
|
||||||
.ToList());
|
.ToList());
|
||||||
|
else return Ok(_context.Invoices
|
||||||
else
|
.Include(x => x.ShippingAddress)
|
||||||
return Ok(_context.Invoices
|
.Include(x => x.LinkedAccount)
|
||||||
.Include("ShippingAddress")
|
.Include(x => x.Products)
|
||||||
.Include(x => x.Products)
|
.ThenInclude(y => y.Product)
|
||||||
.ThenInclude(y => y.Product)
|
.Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList());
|
||||||
.Where(x => x.LinkedAccount != null && x.LinkedAccount.Id == id).ToList());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_logger.LogError(10, e.Message);
|
_logger.LogError(10, e.Message);
|
||||||
return BadRequest();
|
return BadRequest();
|
||||||
|
@ -71,7 +71,8 @@ public class UserController : Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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){
|
} catch (Exception e){
|
||||||
return BadRequest($"Erreur de mot de passe: {e.Message}");
|
return BadRequest($"Erreur de mot de passe: {e.Message}");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user