mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Merge constants
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Podsync.Services.Patreon;
|
||||
using Podsync.Services;
|
||||
|
||||
namespace Podsync.Helpers
|
||||
{
|
||||
@@ -53,7 +53,7 @@ namespace Podsync.Helpers
|
||||
const int MinAmountCents = 100;
|
||||
|
||||
int amount;
|
||||
if (int.TryParse(user.GetClaim(PatreonConstants.AmountDonated), out amount))
|
||||
if (int.TryParse(user.GetClaim(Constants.Patreon.AmountDonated), out amount))
|
||||
{
|
||||
return amount >= MinAmountCents;
|
||||
}
|
||||
|
@@ -7,5 +7,16 @@ namespace Podsync.Services
|
||||
public const int DefaultPageSize = 50;
|
||||
|
||||
public const ResolveType DefaultFormat = ResolveType.VideoHigh;
|
||||
|
||||
public static class Patreon
|
||||
{
|
||||
public const string AuthenticationScheme = "Patreon";
|
||||
|
||||
public const string AuthorizationEndpoint = "https://www.patreon.com/oauth2/authorize";
|
||||
|
||||
public const string TokenEndpoint = "https://api.patreon.com/oauth2/token";
|
||||
|
||||
public const string AmountDonated = "Patreon/" + nameof(AmountDonated);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
namespace Podsync.Services.Patreon
|
||||
{
|
||||
public static class PatreonConstants
|
||||
{
|
||||
public const string AuthenticationScheme = "Patreon";
|
||||
|
||||
public const string AuthorizationEndpoint = "https://www.patreon.com/oauth2/authorize";
|
||||
|
||||
public const string TokenEndpoint = "https://api.patreon.com/oauth2/token";
|
||||
|
||||
public const string AmountDonated = "Patreon/" + nameof(AmountDonated);
|
||||
}
|
||||
}
|
@@ -95,15 +95,15 @@ namespace Podsync
|
||||
// Patreon authentication
|
||||
app.UseOAuthAuthentication(new OAuthOptions
|
||||
{
|
||||
AuthenticationScheme = PatreonConstants.AuthenticationScheme,
|
||||
AuthenticationScheme = Constants.Patreon.AuthenticationScheme,
|
||||
|
||||
ClientId = Configuration[$"Podsync:{nameof(PodsyncConfiguration.PatreonClientId)}"],
|
||||
ClientSecret = Configuration[$"Podsync:{nameof(PodsyncConfiguration.PatreonSecret)}"],
|
||||
|
||||
CallbackPath = new PathString("/oauth-patreon"),
|
||||
|
||||
AuthorizationEndpoint = PatreonConstants.AuthorizationEndpoint,
|
||||
TokenEndpoint = PatreonConstants.TokenEndpoint,
|
||||
AuthorizationEndpoint = Constants.Patreon.AuthorizationEndpoint,
|
||||
TokenEndpoint = Constants.Patreon.TokenEndpoint,
|
||||
|
||||
SaveTokens = true,
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Podsync
|
||||
context.Identity.AddClaim(new Claim(ClaimTypes.Uri, user.Url));
|
||||
|
||||
var amountCents = user.Pledges.Sum(x => x.AmountCents);
|
||||
context.Identity.AddClaim(new Claim(PatreonConstants.AmountDonated, amountCents.ToString()));
|
||||
context.Identity.AddClaim(new Claim(Constants.Patreon.AmountDonated, amountCents.ToString()));
|
||||
|
||||
var telemetry = app.ApplicationServices.GetService<TelemetryClient>();
|
||||
telemetry.TrackEvent("Login", new Dictionary<string, string>
|
||||
@@ -147,7 +147,7 @@ namespace Podsync
|
||||
builder.Run(async context =>
|
||||
{
|
||||
// Return a challenge to invoke the Patreon authentication scheme
|
||||
await context.Authentication.ChallengeAsync(PatreonConstants.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" });
|
||||
await context.Authentication.ChallengeAsync(Constants.Patreon.AuthenticationScheme, new AuthenticationProperties { RedirectUri = "/" });
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user