fixed emial not populating properly

This commit is contained in:
Damien Ostler 2024-01-28 06:25:10 -05:00
parent 52bd3cce1d
commit 21ff5e4b77
11 changed files with 296 additions and 69 deletions

View File

@ -33,8 +33,4 @@
<ProjectReference Include="..\ArtPlatform.Database\ArtPlatform.Database.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="react\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
const namespace = 'http://schemas.microsoft.com/ws/2008/06/identity/claims';
exports.onExecutePostLogin = async (event, api) => {{
api.accessToken.setCustomClaim(namespace+'/emailaddress', event.user.email);
api.accessToken.setCustomClaim(namespace+'/name', event.user.nickname);
var assignedRoles = event.authorization?.roles;
if(assignedRoles!=null && assignedRoles.length>0){
for(var role in assignedRoles){
api.accessToken.setCustomClaim(namespace+'role', assignedRoles[role]);
}
}
}}

View File

@ -0,0 +1,60 @@
using ArtPlatform.Database;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ArtPlatform.API.Controllers;
[ApiController]
[Authorize("admin")]
[Route("api/admin/[controller]")]
public class AdminOrdersController
{
private readonly ApplicationDbContext _dbContext;
public AdminOrdersController(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public Task<IActionResult> GetOrders(string search="", int offset = 0, int pageSize = 10)
{
throw new NotImplementedException();
}
[HttpGet("Count")]
public Task<IActionResult> GetOrdersCount(string search="")
{
throw new NotImplementedException();
}
[HttpGet("{orderId:int}")]
public Task<IActionResult> GetOrder(int orderId)
{
throw new NotImplementedException();
}
[HttpPost("{orderId:int}")]
public Task<IActionResult> SendMessage(int orderId, [FromBody]string message)
{
throw new NotImplementedException();
}
[HttpPut("{orderId:int}/Suspend")]
public Task<IActionResult> SuspendOrder(int orderId)
{
throw new NotImplementedException();
}
[HttpPut("{orderId:int}/Unsuspend")]
public Task<IActionResult> UnsuspendOrder(int orderId)
{
throw new NotImplementedException();
}
[HttpPut("{orderId:int}/Terminate")]
public Task<IActionResult> TerminateOrder(int orderId)
{
throw new NotImplementedException();
}
}

View File

@ -9,12 +9,12 @@ namespace ArtPlatform.API.Controllers;
[ApiController]
[Authorize("admin")]
[Route("api/[controller]")]
public class AdminSellerProfileRequestsController : Controller
[Route("api/admin/[controller]")]
public class AdminSellerRequestsController : Controller
{
private readonly ApplicationDbContext _dbContext;
public AdminSellerProfileRequestsController(ApplicationDbContext dbContext)
public AdminSellerRequestsController(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}

View File

@ -0,0 +1,66 @@
using ArtPlatform.Database;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ArtPlatform.API.Controllers;
[ApiController]
[Authorize("admin")]
[Route("api/admin/[controller]")]
public class AdminSellersController
{
private readonly ApplicationDbContext _dbContext;
public AdminSellersController(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public Task<IActionResult> GetSellers(string search="", int offset = 0, int pageSize = 10)
{
throw new NotImplementedException();
}
[HttpGet("Count")]
public Task<IActionResult> GetSellersCount(string search="")
{
throw new NotImplementedException();
}
[HttpGet("{sellerId:int}")]
public Task<IActionResult> GetSeller(int sellerId)
{
throw new NotImplementedException();
}
[HttpGet("{sellerId:int}/Orders")]
public Task<IActionResult> GetSellerOrders(int sellerId)
{
throw new NotImplementedException();
}
[HttpPut("{sellerId:int}/Suspend")]
public Task<IActionResult> SuspendSeller(int sellerId)
{
throw new NotImplementedException();
}
[HttpPut("{sellerId:int}/Unsuspend")]
public Task<IActionResult> UnsuspendSeller(int sellerId)
{
throw new NotImplementedException();
}
[HttpPut("{sellerId:int}/Terminate")]
public Task<IActionResult> TerminateSeller(int sellerId)
{
throw new NotImplementedException();
}
[HttpPut("{sellerId:int}/SetBiography")]
public Task<IActionResult> SetBiography(string userId, [FromBody]string biography)
{
throw new NotImplementedException();
}
}

View File

@ -0,0 +1,73 @@
using ArtPlatform.Database;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ArtPlatform.API.Controllers;
[ApiController]
[Authorize("admin")]
[Route("api/admin/[controller]")]
public class AdminUsersController
{
private readonly ApplicationDbContext _dbContext;
public AdminUsersController(ApplicationDbContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public Task<IActionResult> GetUsers(string search="", int offset = 0, int pageSize = 10)
{
throw new NotImplementedException();
}
[HttpGet("Count")]
public Task<IActionResult> GetUsersCount(string search="")
{
throw new NotImplementedException();
}
[HttpGet("{userId}")]
public Task<IActionResult> GetUser(string userId)
{
throw new NotImplementedException();
}
[HttpGet("{userId}/Orders")]
public Task<IActionResult> GetUserOrders(string userId)
{
throw new NotImplementedException();
}
[HttpPut("{userId}/Suspend")]
public Task<IActionResult> SuspendUser(string userId)
{
throw new NotImplementedException();
}
[HttpPut("{userId}/Unsuspend")]
public Task<IActionResult> UnsuspendUser(string userId)
{
throw new NotImplementedException();
}
[HttpPut("{userId}/Terminate")]
public Task<IActionResult> TerminateUser(string userId)
{
throw new NotImplementedException();
}
[HttpPut("{userId}/SetDisplayName")]
public Task<IActionResult> SetDisplayName(string userId, [FromBody]string displayName)
{
throw new NotImplementedException();
}
[HttpPut("{userId}/SetBiography")]
public Task<IActionResult> SetBiography(string userId, [FromBody]string biography)
{
throw new NotImplementedException();
}
}

View File

@ -60,7 +60,7 @@ public class OrderController : Controller
{
var session = stripeEvent.Data.Object as Session;
var connectedAccountId = stripeEvent.Account;
var orderId = session.Metadata["orderId"];
var orderId = session.Metadata["/OrderId"];
var order = await _dbContext.SellerServiceOrders
.Include(x=>x.Seller)
.Include(x=>x.SellerService)
@ -77,7 +77,7 @@ public class OrderController : Controller
}
[HttpGet]
[Route("Orders")]
[Route("/Orders")]
[Authorize("read:orders")]
public async Task<IActionResult> GetOrders(int offset = 0, int pageSize = 10, EnumOrderStatus? status = null)
{
@ -88,9 +88,20 @@ public class OrderController : Controller
var result = orders.Select(x => x.ToModel()).ToList();
return Ok(result);
}
[HttpGet]
[Route("/Orders/{orderId:int}")]
[Authorize("read:orders")]
public async Task<IActionResult> GetOrder(int orderId,int offset = 0, int pageSize = 10, EnumOrderStatus? status = null)
{
var userId = User.GetUserId();
var order = await _dbContext.SellerServiceOrders
.FirstAsync(x => x.Id==orderId && x.BuyerId == userId && status == null ? true : status == x.Status);
var result = order.ToModel();
return Ok(result);
}
[HttpPost]
[Route("Sellers/{sellerId:int}/Services/{serviceId:int}")]
[Route("/Sellers/{sellerId:int}/Services/{serviceId:int}")]
[Authorize("write:orders")]
public async Task<IActionResult> CreateOrder(int sellerId, int serviceId)
{
@ -128,7 +139,7 @@ public class OrderController : Controller
[HttpDelete]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}")]
[Route("/api/Orders/{orderId:int}")]
public async Task<IActionResult> CancelOrder(int orderId)
{
var userId = User.GetUserId();
@ -136,11 +147,11 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.BuyerId!=userId)
return BadRequest("You are not the buyer of this order.");
if(order.Status==EnumOrderStatus.Completed)
return BadRequest("Order is not in a cancellable state.");
return BadRequest("/Order is not in a cancellable state.");
order.Status = EnumOrderStatus.Cancelled;
order.EndDate = DateTime.UtcNow;
order = _dbContext.SellerServiceOrders.Update(order).Entity;
@ -151,7 +162,7 @@ public class OrderController : Controller
[HttpPut]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/AcceptPrice")]
[Route("/api/Orders/{orderId:int}/AcceptPrice")]
public async Task<IActionResult> AcceptPrice(int orderId)
{
var userId = User.GetUserId();
@ -161,19 +172,19 @@ public class OrderController : Controller
.Include(x=>x.Seller)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.Seller.UserId!=userId)
return BadRequest("You are not the seller of this order.");
if(order.Status==EnumOrderStatus.Completed)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status<EnumOrderStatus.DiscussingRequirements)
return BadRequest("Order has not been started yet.");
return BadRequest("/Order has not been started yet.");
if(string.IsNullOrEmpty(order.PaymentUrl)==false)
return BadRequest("Order has price already been agreed on.");
return BadRequest("/Order has price already been agreed on.");
if(order.Status==EnumOrderStatus.WaitingForPayment)
return BadRequest("Order is waiting for payment.");
return BadRequest("/Order is waiting for payment.");
order.TermsAcceptedDate = DateTime.UtcNow;
@ -196,7 +207,7 @@ public class OrderController : Controller
}
[HttpPut]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Payment")]
[Route("/api/Orders/{orderId:int}/Payment")]
public async Task<IActionResult> Payment(int orderId)
{
var userId = User.GetUserId();
@ -206,15 +217,15 @@ public class OrderController : Controller
.Include(x=>x.Seller)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.Seller.UserId!=userId)
return BadRequest("You are not the seller of this order.");
if(order.Status==EnumOrderStatus.Completed)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status!=EnumOrderStatus.WaitingForPayment)
return BadRequest("Order does not need to be paid for.");
if(order.PaymentUrl!=null)
return BadRequest("Order has already has a payment url.");
return BadRequest("/Order does not need to be paid for.");
if (order.PaymentUrl != null)
return Ok(order.PaymentUrl);
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
order.PaymentUrl = url;
order = _dbContext.SellerServiceOrders.Update(order).Entity;
@ -224,7 +235,7 @@ public class OrderController : Controller
[HttpPut]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Accept")]
[Route("/api/Orders/{orderId:int}/Accept")]
public async Task<IActionResult> Accept(int orderId)
{
var userId = User.GetUserId();
@ -233,17 +244,17 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.Seller.UserId!=userId)
return BadRequest("You are not the seller of this order.");
if(order.Status==EnumOrderStatus.Completed)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status<EnumOrderStatus.InProgress)
return BadRequest("Order has not been started yet.");
return BadRequest("/Order has not been started yet.");
if(order.Status<EnumOrderStatus.PendingReview)
return BadRequest("Order is in progress and not pending review.");
return BadRequest("/Order is in progress and not pending review.");
if(order.Status==EnumOrderStatus.WaitingForPayment)
return BadRequest("Order is waiting for payment.");
return BadRequest("/Order is waiting for payment.");
if(order.Seller.PrepaymentRequired)
order.Status = EnumOrderStatus.Completed;
@ -263,7 +274,7 @@ public class OrderController : Controller
[HttpDelete]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Deny")]
[Route("/api/Orders/{orderId:int}/Deny")]
public async Task<IActionResult> Deny(int orderId)
{
var userId = User.GetUserId();
@ -272,15 +283,15 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.Seller.UserId!=userId)
return BadRequest("You are not the seller of this order.");
if(order.Status==EnumOrderStatus.Completed)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status<EnumOrderStatus.InProgress)
return BadRequest("Order has not been started yet.");
return BadRequest("/Order has not been started yet.");
if(order.Status<EnumOrderStatus.PendingReview)
return BadRequest("Order is in progress and not pending review.");
return BadRequest("/Order is in progress and not pending review.");
order.Status = EnumOrderStatus.InProgress;
order.TermsAcceptedDate = DateTime.UtcNow;
order = _dbContext.SellerServiceOrders.Update(order).Entity;
@ -291,7 +302,7 @@ public class OrderController : Controller
[HttpPost]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Review")]
[Route("/api/Orders/{orderId:int}/Review")]
public async Task<IActionResult> Review(int orderId, [FromBody] SellerServiceOrderReviewModel model)
{
var userId = User.GetUserId();
@ -301,13 +312,13 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.BuyerId!=userId)
return BadRequest("You are not the buyer of this order.");
if(order.Status!=EnumOrderStatus.Completed)
return BadRequest("Order is not complete.");
return BadRequest("/Order is not complete.");
if(order.Reviews.Any(x=>x.SellerServiceOrderId==orderId))
return BadRequest("Order has already been reviewed.");
return BadRequest("/Order has already been reviewed.");
var review = new SellerServiceOrderReview()
{
SellerServiceOrderId = orderId,
@ -325,7 +336,7 @@ public class OrderController : Controller
[HttpGet]
[Authorize("read:orders")]
[Route("Orders/{orderId:int}/Messages")]
[Route("/api/Orders/{orderId:int}/Messages")]
public async Task<IActionResult> GetMessages(int orderId, int offset = 0, int pageSize = 10)
{
var userId = User.GetUserId();
@ -333,7 +344,7 @@ public class OrderController : Controller
.Include(x=>x.Seller)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
return BadRequest("You are not the buyer or seller of this order.");
var messages = _dbContext.SellerServiceOrderMessages
@ -348,7 +359,7 @@ public class OrderController : Controller
[HttpPost]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Message")]
[Route("/api/Orders/{orderId:int}/Message")]
public async Task<IActionResult> Message(int orderId, [FromBody] SellerServiceOrderMessageModel model)
{
var userId = User.GetUserId();
@ -358,13 +369,13 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
return BadRequest("You are not the buyer or seller of this order.");
if(order.Status<EnumOrderStatus.Waitlist)
return BadRequest("Order is not accepted.");
return BadRequest("/Order is not accepted.");
var message = new SellerServiceOrderMessage()
{
SellerServiceOrderId = orderId,
@ -380,7 +391,7 @@ public class OrderController : Controller
[HttpPost]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
[Route("/api/Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
public async Task<IActionResult> MessageAttachment(int orderId, int messageId,IFormFile file)
{
var userId = User.GetUserId();
@ -390,13 +401,13 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
return BadRequest("You are not the buyer or seller of this order.");
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status<EnumOrderStatus.Waitlist)
return BadRequest("Order is not accepted.");
return BadRequest("/Order is not accepted.");
var message = _dbContext.SellerServiceOrderMessages.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);
if(message==null)
@ -414,7 +425,7 @@ public class OrderController : Controller
}
[HttpGet]
[Authorize("read:orders")]
[Route("Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
[Route("/api/Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
public async Task<IActionResult> MessageAttachments(int orderId, int messageId)
{
var userId = User.GetUserId();
@ -424,13 +435,13 @@ public class OrderController : Controller
.Include(x=>x.SellerService)
.FirstOrDefaultAsync(x=>x.Id==orderId);
if(order==null)
return NotFound("Order not found.");
return NotFound("/Order not found.");
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
return BadRequest("You are not the buyer or seller of this order.");
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
return BadRequest("Order is already complete.");
return BadRequest("/Order is already complete.");
if(order.Status<EnumOrderStatus.Waitlist)
return BadRequest("Order is not accepted.");
return BadRequest("/Order is not accepted.");
var message = _dbContext.SellerServiceOrderMessages.Include(x=>x.Attachments)
.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);

View File

@ -24,7 +24,7 @@ public class SellerOrderController : Controller
}
[HttpGet]
[Route("Orders")]
[Route("/SellerOrders")]
[Authorize("read:seller-orders")]
public async Task<IActionResult> GetOrders(int offset = 0, int pageSize = 10, EnumOrderStatus? status = null)
{
@ -36,10 +36,22 @@ public class SellerOrderController : Controller
var result = orders.Select(x => x.ToModel()).ToList();
return Ok(result);
}
[HttpGet]
[Route("/SellerOrders/{orderId:int}")]
[Authorize("read:seller-orders")]
public async Task<IActionResult> GetOrder(int orderId, int offset = 0, int pageSize = 10, EnumOrderStatus? status = null)
{
var userId = User.GetUserId();
var order = await _dbContext.SellerServiceOrders
.Include(x => x.Seller)
.FirstAsync(x => x.Id==orderId && x.Seller.UserId == userId && status == null ? true : status == x.Status);
var result = order.ToModel();
return Ok(result);
}
[HttpDelete]
[Authorize("write:seller-orders")]
[Route("Orders/{orderId:int}/Cancel")]
[Route("/api/SellerOrders/{orderId:int}/Cancel")]
public async Task<IActionResult> CancelOrder(int orderId)
{
var userId = User.GetUserId();
@ -64,7 +76,7 @@ public class SellerOrderController : Controller
[HttpPut]
[Authorize("write:seller-orders")]
[Route("Orders/{orderId:int}/Accept")]
[Route("/api/SellerOrders/{orderId:int}/Accept")]
public async Task<IActionResult> AcceptOrder(int orderId)
{
var userId = User.GetUserId();
@ -88,7 +100,7 @@ public class SellerOrderController : Controller
[HttpPut]
[Authorize("write:seller-orders")]
[Route("Orders/{orderId:int}/Start")]
[Route("/api/SellerOrders/{orderId:int}/Start")]
public async Task<IActionResult> StartOrder(int orderId)
{
var userId = User.GetUserId();
@ -112,7 +124,7 @@ public class SellerOrderController : Controller
[HttpPut]
[Authorize("write:seller-orders")]
[Route("Orders/{orderId:int}/AdjustPrice")]
[Route("/api/SellerOrders/{orderId:int}/AdjustPrice")]
public async Task<IActionResult> AdjustPrice(int orderId,[FromQuery]double price)
{
var userId = User.GetUserId();
@ -139,7 +151,7 @@ public class SellerOrderController : Controller
[HttpPut]
[Authorize("write:seller-orders")]
[Route("Orders/{orderId:int}/CompleteRevision")]
[Route("/api/SellerOrders/{orderId:int}/CompleteRevision")]
public async Task<IActionResult> CompleteRevision(int orderId)
{
var userId = User.GetUserId();
@ -166,7 +178,7 @@ public class SellerOrderController : Controller
[HttpGet]
[Authorize("read:orders")]
[Route("Orders/{orderId:int}/Messages")]
[Route("/api/SellerOrders/{orderId:int}/Messages")]
public async Task<IActionResult> GetMessages(int orderId, int offset = 0, int pageSize = 10)
{
var userId = User.GetUserId();
@ -188,7 +200,7 @@ public class SellerOrderController : Controller
}
[HttpPost]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Message")]
[Route("/api/SellerOrders/{orderId:int}/Message")]
public async Task<IActionResult> Message(int orderId, [FromBody] SellerServiceOrderMessageModel model)
{
var userId = User.GetUserId();
@ -220,7 +232,7 @@ public class SellerOrderController : Controller
[HttpPost]
[Authorize("write:orders")]
[Route("Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
[Route("/api/SellerOrders/{orderId:int}/Message/{messageId:int}/Attachment")]
public async Task<IActionResult> MessageAttachment(int orderId, int messageId,IFormFile file)
{
var userId = User.GetUserId();
@ -254,7 +266,7 @@ public class SellerOrderController : Controller
}
[HttpGet]
[Authorize("read:orders")]
[Route("Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
[Route("/api/SellerOrders/{orderId:int}/Message/{messageId:int}/Attachment")]
public async Task<IActionResult> MessageAttachments(int orderId, int messageId)
{
var userId = User.GetUserId();

View File

@ -28,7 +28,7 @@ public class UserMiddleware
user = new User
{
Id = userId,
DisplayName = context.User.Identity.Name ?? "Anonymous",
DisplayName = context.User.Claims.FirstOrDefault(x=>x.Type==ClaimTypes.Name)?.Value ?? "Anonymous",
Biography = string.Empty,
Email = context.User.Claims.FirstOrDefault(x=>x.Type==ClaimTypes.Email)?.Value ?? string.Empty,
};
@ -36,10 +36,10 @@ public class UserMiddleware
await dbContext.SaveChangesAsync();
}
else
{
{
user.Email= context.User.Claims.FirstOrDefault(x=>x.Type==ClaimTypes.Email)?.Value ?? string.Empty;
dbContext.Users.Update(user);
await dbContext.SaveChangesAsync();
await dbContext.SaveChangesAsync();
}
}

View File

@ -16,7 +16,6 @@ public static class UserInfoModelExtensions
{
existingUser.DisplayName = user.DisplayName;
existingUser.Biography = user.Biography;
existingUser.Email = user.Email;
return existingUser;
}
}

View File

@ -4,5 +4,4 @@ public class UserInfoUpdateModel
{
public string DisplayName { get; init; } = string.Empty;
public string Biography { get; init; } = string.Empty;
public string Email { get; init; } = string.Empty;
}