#27 get last receipt, get minimalUser, get my user
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Hutopy.Domain.Interfaces;
|
||||
using System.Security.Claims;
|
||||
using Hutopy.Domain.Interfaces;
|
||||
using Hutopy.Domain.Models;
|
||||
using Hutopy.Infrastructure.Identity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Hutopy.Infrastructure.Services;
|
||||
|
||||
public class UserService(UserManager<ApplicationUser> userManager) : IUserService
|
||||
public class UserService(UserManager<ApplicationUser> userManager, IHttpContextAccessor contextAccessor) : IUserService
|
||||
{
|
||||
public async Task CreateUserAsync(string email, string userName, string firstName, string lastName, string password)
|
||||
{
|
||||
@@ -38,7 +40,7 @@ public class UserService(UserManager<ApplicationUser> userManager) : IUserServic
|
||||
UserName = response.UserName,
|
||||
FirstName = response.FirstName,
|
||||
LastName = response.LastName,
|
||||
Email = response.Email
|
||||
Email = response.Email,
|
||||
};
|
||||
|
||||
return userModel;
|
||||
@@ -47,13 +49,13 @@ public class UserService(UserManager<ApplicationUser> userManager) : IUserServic
|
||||
public async Task<UserModel?> GetCurrentUserAsync()
|
||||
{
|
||||
// todo: Get the id of the user doing the request.
|
||||
var userId = "";
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
var currentUserId = contextAccessor.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
if (string.IsNullOrEmpty(currentUserId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return await FindUserByIdAsync(userId);
|
||||
return await FindUserByIdAsync(currentUserId);
|
||||
}
|
||||
|
||||
public async Task<UserModel?> FindUserByEmailAsync(string email)
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Hutopy.Infrastructure.Stripe;
|
||||
|
||||
public class StripeService : IStripeService
|
||||
{
|
||||
const string EndpointSecret = "";
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public StripeService(IHttpContextAccessor httpContextAccessor)
|
||||
@@ -18,7 +17,7 @@ public class StripeService : IStripeService
|
||||
StripeConfiguration.ApiKey = "";
|
||||
}
|
||||
|
||||
public async Task<string> CreateCheckoutSession(int amount, string currency = "cad")
|
||||
public async Task<string> CreateCheckoutSession(int amount, string creatorId, string currency = "cad")
|
||||
{
|
||||
var options = new SessionCreateOptions
|
||||
{
|
||||
@@ -38,7 +37,9 @@ public class StripeService : IStripeService
|
||||
],
|
||||
Mode = "payment",
|
||||
UiMode = "embedded",
|
||||
ReturnUrl = "https://hutopy.ca/paymentcompleted",
|
||||
ReturnUrl = $"https://hutopy.ca/paymentcompleted?creatorId={creatorId}",
|
||||
InvoiceCreation = new SessionInvoiceCreationOptions(){ Enabled = true},
|
||||
ClientReferenceId = creatorId
|
||||
};
|
||||
|
||||
var service = new SessionService();
|
||||
@@ -57,7 +58,6 @@ public class StripeService : IStripeService
|
||||
}
|
||||
|
||||
return new Result(false, new List<string>());
|
||||
|
||||
}
|
||||
catch (StripeException e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user