Skip to content

Instantly share code, notes, and snippets.

flags enabled: promo_parties_and_roles, promo_parties_and_roles_create_dummy_user
script to backpopulate dummy user has been run
1. New user, validation errors on submit
starting at /new
new user i.e. "Create a new user"
select "Business" account type
=> [ok] expect Company Name to be enabled, blanked, searchable
=> [ok] expect NZBN to be enabled, blanked, searchable
// Startup.cs
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
docker stop sql_server
docker start sql_server
// Pages/Post/Edit.razor
<div class="row">
<div class="col-6">
<input type="hidden" @bind-value="@post.Body" />
<textarea rows="20" class="form-control" id="body" @bind="@post.Body" @bind:event="oninput" />
</div>
<div class="col-6">
@((MarkupString) post.MarkupString)
</div>
// Post.cs
using Markdig;
namespace Golb.Data
{
public class Post
{
... etc
public string MarkupString {
dotnet add package Markdig --version 0.22.0
// Pages/Post/New.razor
@page "/posts/new"
@attribute [Authorize(Roles = "Admin")]
... etc
// Pages/Post/Index.razor
<AuthorizeView Roles="Admin">
<div class="form-group float-right">
<a class="btn btn-success" href="posts/new">
<i class="oi oi-plus"></i>
&nbsp; New Post
</a>
</div>
</AuthorizeView>
// Startup.cs
...etc
using Microsoft.AspNetCore.Authorization;
public void ConfigureServices(IServiceCollection services)
{
... etc
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
// Data/ApplicationInitialiser.cs
using Microsoft.AspNetCore.Identity;
using System.Threading.Tasks;
public static class ApplicationInitialiser
{
private const string ADMIN_ROLE = "Admin";
public static async Task Initialise(UserManager<IdentityUser> userManager, RoleManager<IdentityRole> roleManager)