Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include VerifiedEmailForPluginPublish feature flag #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions PluginBuilder/Controllers/PluginController.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
using Microsoft.AspNetCore.Authorization;
using Dapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.FeatureManagement;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PluginBuilder.Components.PluginVersion;
using PluginBuilder.ModelBinders;
using PluginBuilder.Services;
using PluginBuilder.ViewModels;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using PluginBuilder.Components.PluginVersion;

namespace PluginBuilder.Controllers
{
[Authorize(Policy = Policies.OwnPlugin)]
[Route("/plugins/{pluginSlug}")]
public class PluginController(
DBConnectionFactory connectionFactory,
UserManager<IdentityUser> userManager,
IFeatureManager featureManager,
BuildService buildService,
EmailService emailService,
EventAggregator eventAggregator)
: Controller
{
private DBConnectionFactory ConnectionFactory { get; } = connectionFactory;
private UserManager<IdentityUser> UserManager { get; } = userManager;
private BuildService BuildService { get; } = buildService;
private EventAggregator EventAggregator { get; } = eventAggregator;

Expand Down Expand Up @@ -103,6 +109,15 @@ public async Task<IActionResult> CreateBuild(
{
if (!ModelState.IsValid)
return View(model);
var user = await UserManager.GetUserAsync(User);
var emailSettings = await emailService.GetEmailSettingsFromDb();
var needToVerifyEmail = emailSettings?.PasswordSet == true && !await UserManager.IsEmailConfirmedAsync(user!);
var isEmailVerificationFeatureEnabled = await featureManager.IsEnabledAsync("VerifiedEmailForPluginPublish");
if (isEmailVerificationFeatureEnabled && needToVerifyEmail)
{
TempData[TempDataConstant.WarningMessage] = "You need to verify your email address to complete the plugin build process";
return RedirectToAction("AccountDetails", "Account");
}
await using var conn = await ConnectionFactory.Open();
var buildId = await conn.NewBuild(pluginSlug, model.ToBuildParameter());
_ = BuildService.Build(new FullBuildId(pluginSlug, buildId));
Expand Down
1 change: 1 addition & 0 deletions PluginBuilder/PluginBuilder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.10" />
<PackageReference Include="Microsoft.FeatureManagement" Version="4.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 3 additions & 0 deletions PluginBuilder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.FeatureManagement;
using Npgsql;
using PluginBuilder.Authentication;
using PluginBuilder.DataModels;
Expand Down Expand Up @@ -39,6 +40,7 @@ public WebApplicationBuilder CreateWebApplicationBuilder(string[]? args = null)
{
var builder = WebApplication.CreateBuilder(args ?? Array.Empty<string>());
builder.Configuration.AddEnvironmentVariables("PB_");
builder.Configuration.AddEnvironmentVariables("FeatureManagement__");
#if DEBUG
builder.Logging.AddFilter(typeof(ProcessRunner).FullName, LogLevel.Trace);
#endif
Expand Down Expand Up @@ -99,6 +101,7 @@ public void AddServices(IConfiguration configuration, IServiceCollection service
services.AddSingleton<ServerEnvironment>();
services.AddSingleton<EventAggregator>();
services.AddSingleton<EmailService>();
services.AddFeatureManagement();

services.AddDbContext<IdentityDbContext<IdentityUser>>(b =>
{
Expand Down
3 changes: 2 additions & 1 deletion PluginBuilder/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"ASPNETCORE_ENVIRONMENT": "Development",
"PB_POSTGRES": "User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=61932;Database=btcpayplugin",
"PB_STORAGE_CONNECTION_STRING": "BlobEndpoint=http://127.0.0.1:32827/satoshi;AccountName=satoshi;AccountKey=Rxb41pUHRe+ibX5XS311tjXpjvu7mVi2xYJvtmq1j2jlUpN+fY/gkzyBMjqwzgj42geXGdYSbPEcu5i5wjSjPw==",
"PB_CHEAT_MODE": "true"
"PB_CHEAT_MODE": "true",
"FeatureManagement__VerifiedEmailForPluginPublish": "true"
}
}
}
Expand Down