User login logout

This commit is contained in:
Martijn Scheepers
2020-04-01 15:25:27 +02:00
parent 1805166843
commit f62c6f7f9c
23 changed files with 1368 additions and 758 deletions

View File

@@ -13,9 +13,9 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public class CustomUserStore : IUserStore<IdentityUser>, IUserPasswordStore<IdentityUser>
{
private String GetUserDirectoryPath(string location)
private String GetUserDirectoryPath()
{
string directory = Directory.GetCurrentDirectory() + "\\DataStore\\" + location + "\\Users\\";
string directory = Directory.GetCurrentDirectory() + "\\DataStore\\Users\\";
if (Directory.Exists(directory) == false)
{
Directory.CreateDirectory(directory);
@@ -23,9 +23,9 @@ namespace Arrestanten_planbord.Areas.Identity.Data
return directory;
}
private String GetUserFilePath(string fileName, string location)
private String GetUserFilePath(string fileName)
{
return GetUserDirectoryPath(location) + fileName + ".json";
return GetUserDirectoryPath() + fileName + ".json";
}
private IdentityUser ReadIdentityUserFile(string filePath)
@@ -53,14 +53,14 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public async Task<IdentityResult> CreateAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("CreateAsync");
Debug.WriteLine("Area CreateAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
//return await _usersTable.CreateAsync(user);
string filePath = GetUserFilePath(user.NormalizedUserName, "Eindhoven");
string filePath = GetUserFilePath(user.NormalizedUserName);
if (File.Exists(filePath) == true)
{
@@ -88,12 +88,12 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public async Task<IdentityResult> DeleteAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("DeleteAsync");
Debug.WriteLine("Area DeleteAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
string filePath = GetUserFilePath(user.NormalizedUserName, "Eindhoven");
string filePath = GetUserFilePath(user.NormalizedUserName);
if (File.Exists(filePath) == true)
{
try
@@ -117,7 +117,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<IdentityUser> FindByIdAsync(string userId, CancellationToken cancellationToken)
{
Debug.WriteLine("FindByIdAsync");
Debug.WriteLine("Area FindByIdAsync");
if (userId == null) throw new ArgumentNullException(nameof(userId));
Guid idGuid;
@@ -129,7 +129,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
//return await _usersTable.FindByIdAsync(idGuid);
string[] userFiles = Directory.GetFiles(GetUserDirectoryPath("Eindhoven"));
string[] userFiles = Directory.GetFiles(GetUserDirectoryPath());
foreach (var file in userFiles)
{
@@ -149,14 +149,14 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<IdentityUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
{
Debug.WriteLine("FindByNameAsync");
Debug.WriteLine("Area FindByNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (normalizedUserName == null) throw new ArgumentNullException(nameof(normalizedUserName));
//return await _usersTable.FindByNameAsync(userName);
string filepath = GetUserFilePath(normalizedUserName, "Eindhoven");
string filepath = GetUserFilePath(normalizedUserName);
if (File.Exists(filepath) == true)
{
@@ -169,7 +169,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<string> GetNormalizedUserNameAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetNormalizedUserNameAsync");
Debug.WriteLine("Area GetNormalizedUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -179,7 +179,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<string> GetUserIdAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetUserIdAsync");
Debug.WriteLine("Area GetUserIdAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -189,7 +189,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<string> GetUserNameAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetUserNameAsync");
Debug.WriteLine("Area GetUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -199,7 +199,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task SetNormalizedUserNameAsync(IdentityUser user, string normalizedName, CancellationToken cancellationToken)
{
Debug.WriteLine("SetNormalizedUserNameAsync");
Debug.WriteLine("Area SetNormalizedUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -211,7 +211,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task SetUserNameAsync(IdentityUser user, string userName, CancellationToken cancellationToken)
{
Debug.WriteLine("SetUserNameAsync");
Debug.WriteLine("Area SetUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -222,7 +222,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<IdentityResult> UpdateAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("UpdateAsync");
Debug.WriteLine("Area UpdateAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -234,7 +234,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task SetPasswordHashAsync(IdentityUser user, string passwordHash, CancellationToken cancellationToken)
{
Debug.WriteLine("SetPasswordHashAsync");
Debug.WriteLine("Area SetPasswordHashAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -246,7 +246,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<string> GetPasswordHashAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetPasswordHashAsync");
Debug.WriteLine("Area GetPasswordHashAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
@@ -256,7 +256,7 @@ namespace Arrestanten_planbord.Areas.Identity.Data
public Task<bool> HasPasswordAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("HasPasswordAsync");
Debug.WriteLine("Area HasPasswordAsync");
return Task.FromResult(true);
}

View File

@@ -2,6 +2,7 @@
@using Microsoft.AspNetCore.Identity
@attribute [IgnoreAntiforgeryToken]
@inject SignInManager<IdentityUser> SignInManager
@functions {
public async Task<IActionResult> OnPost()
{

View File

@@ -17,6 +17,7 @@
<PackageReference Include="Blazorise" Version="0.8.8.4" />
<PackageReference Include="Blazorise.Bootstrap" Version="0.8.8.4" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.8.8.4" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.3" />

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
namespace Arrestanten_planbord.Controllers
{
public class AccountController : Controller
{
private readonly UserManager<IdentityUser> _userManager;
private readonly SignInManager<IdentityUser> _signInManager;
private readonly IDataProtector _dataProtector;
public AccountController(IDataProtectionProvider dataProtectionProvider, UserManager<IdentityUser> userManager, SignInManager<IdentityUser> signInManager)
{
_dataProtector = dataProtectionProvider.CreateProtector("SignIn");
_userManager = userManager;
_signInManager = signInManager;
}
[HttpGet("account/signinactual")]
public async Task<IActionResult> SignInActual(string t)
{
var data = _dataProtector.Unprotect(t);
var parts = data.Split('|');
//Debug.WriteLine("part[0] = " + parts[0]);
//Debug.WriteLine("part[1] = " + parts[1]);
//Debug.WriteLine("part[2] = " + parts[2]);
//Debug.WriteLine("part[3] = " + parts[3]);
var identityUser = await _userManager.FindByIdAsync(parts[0]);
var isTokenValid = await _userManager.VerifyUserTokenAsync(identityUser, TokenOptions.DefaultProvider, "SignIn", parts[1]);
bool rememberMe = false;
if (parts[2] == "True")
{
rememberMe = true;
}
Debug.WriteLine("remember me = " + rememberMe);
if (isTokenValid)
{
await _signInManager.SignInAsync(identityUser, rememberMe);
return Redirect("/");
}
else
{
return Unauthorized("STOP!");
}
}
[Authorize]
[HttpGet("account/signout")]
public async Task<IActionResult> SignOut()
{
await _signInManager.SignOutAsync();
return Redirect("/");
}
}
}

View File

@@ -1,16 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
//using System;
//using System.Collections.Generic;
//using System.Text;
//using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
//using Microsoft.EntityFrameworkCore;
namespace Arrestanten_planbord.Data
{
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
}
//namespace Arrestanten_planbord.Data
//{
// public class ApplicationDbContext : IdentityDbContext
// {
// public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
// : base(options)
// {
// }
// }
//}

View File

@@ -0,0 +1,264 @@
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
namespace Arrestanten_planbord.Data
{
public class CustomUserStore : IUserStore<IdentityUser>, IUserPasswordStore<IdentityUser>
{
private String GetUserDirectoryPath()
{
string directory = Directory.GetCurrentDirectory() + "\\DataStore\\Users\\";
if (Directory.Exists(directory) == false)
{
Directory.CreateDirectory(directory);
}
return directory;
}
private String GetUserFilePath(string fileName)
{
return GetUserDirectoryPath() + fileName + ".json";
}
private IdentityUser ReadIdentityUserFile(string filePath)
{
FileStream fileStream = new FileStream(filePath, FileMode.Open);
String json;
using (StreamReader reader = new StreamReader(fileStream))
{
json = reader.ReadToEnd();
}
return JsonSerializer.Deserialize(json, typeof(IdentityUser)) as IdentityUser;
}
//private void WriteCustomUserFile(IdentityUser user, string filePath)
//{
// var options = new JsonSerializerOptions
// {
// WriteIndented = true
// };
// File.WriteAllText(filePath, JsonSerializer.Serialize(user, options));
//}
//IUserStore
public async Task<IdentityResult> CreateAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("CreateAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
//return await _usersTable.CreateAsync(user);
string filePath = GetUserFilePath(user.NormalizedUserName);
if (File.Exists(filePath) == true)
{
return IdentityResult.Failed(new IdentityError() { Description = $"User already exists {user.UserName}." });
}
var options = new JsonSerializerOptions
{
WriteIndented = true
};
try
{
File.WriteAllText(filePath, JsonSerializer.Serialize(user, options));
}
catch (Exception ex)
{
return IdentityResult.Failed(new IdentityError() { Description = $"Could not create user {user.UserName}. exeption = { ex.Message} " });
}
//WriteCustomUserFile(user, filePath);
return IdentityResult.Success;
}
public async Task<IdentityResult> DeleteAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("DeleteAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
string filePath = GetUserFilePath(user.NormalizedUserName);
if (File.Exists(filePath) == true)
{
try
{
File.Delete(filePath);
}
catch (Exception ex)
{
return IdentityResult.Failed(new IdentityError() { Description = $"Could not delete user {user.UserName}. exeption = { ex.Message} " });
}
return IdentityResult.Success;
}
return IdentityResult.Failed(new IdentityError() { Description = $"Could not delete user {user.UserName}." });
}
public void Dispose()
{
Debug.WriteLine("Dispose");
}
public Task<IdentityUser> FindByIdAsync(string userId, CancellationToken cancellationToken)
{
Debug.WriteLine("FindByIdAsync");
if (userId == null) throw new ArgumentNullException(nameof(userId));
Guid idGuid;
if (!Guid.TryParse(userId, out idGuid))
{
throw new ArgumentException("Not a valid Guid id", nameof(userId));
}
//return await _usersTable.FindByIdAsync(idGuid);
string[] userFiles = Directory.GetFiles(GetUserDirectoryPath());
foreach (var file in userFiles)
{
Debug.WriteLine("file = " + file);
IdentityUser user = ReadIdentityUserFile(file);
if (user.Id == userId)
{
return Task.FromResult(user);
}
}
throw new NotImplementedException();
}
public Task<IdentityUser> FindByNameAsync(string normalizedUserName, CancellationToken cancellationToken)
{
Debug.WriteLine("FindByNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (normalizedUserName == null) throw new ArgumentNullException(nameof(normalizedUserName));
//return await _usersTable.FindByNameAsync(userName);
string filepath = GetUserFilePath(normalizedUserName);
if (File.Exists(filepath) == true)
{
IdentityUser user = ReadIdentityUserFile(filepath);
return Task.FromResult(user);
}
return Task.FromResult((IdentityUser)null);
}
public Task<string> GetNormalizedUserNameAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetNormalizedUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
return Task.FromResult(user.UserName.ToUpperInvariant());
}
public Task<string> GetUserIdAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetUserIdAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
return Task.FromResult(user.Id);
}
public Task<string> GetUserNameAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
return Task.FromResult(user.UserName);
}
public Task SetNormalizedUserNameAsync(IdentityUser user, string normalizedName, CancellationToken cancellationToken)
{
Debug.WriteLine("SetNormalizedUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
if (normalizedName == null) throw new ArgumentNullException(nameof(normalizedName));
user.NormalizedUserName = normalizedName;
return Task.FromResult<object>(null);
}
public Task SetUserNameAsync(IdentityUser user, string userName, CancellationToken cancellationToken)
{
Debug.WriteLine("SetUserNameAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
if (userName == null) throw new ArgumentNullException(nameof(userName));
throw new NotImplementedException();
}
public Task<IdentityResult> UpdateAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("UpdateAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
throw new NotImplementedException();
}
//IUserPasswordStore
public Task SetPasswordHashAsync(IdentityUser user, string passwordHash, CancellationToken cancellationToken)
{
Debug.WriteLine("SetPasswordHashAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
if (passwordHash == null) throw new ArgumentNullException(nameof(passwordHash));
user.PasswordHash = passwordHash;
return Task.FromResult<object>(null);
}
public Task<string> GetPasswordHashAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("GetPasswordHashAsync");
cancellationToken.ThrowIfCancellationRequested();
if (user == null) throw new ArgumentNullException(nameof(user));
return Task.FromResult(user.PasswordHash);
}
public Task<bool> HasPasswordAsync(IdentityUser user, CancellationToken cancellationToken)
{
Debug.WriteLine("HasPasswordAsync");
return Task.FromResult(true);
}
}
}

View File

@@ -1,277 +1,277 @@
// <auto-generated />
using System;
using Arrestanten_planbord.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Arrestanten_planbord.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("00000000000000_CreateIdentitySchema")]
partial class CreateIdentitySchema
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
//// <auto-generated />
//using System;
//using Arrestanten_planbord.Data;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.EntityFrameworkCore.Infrastructure;
//using Microsoft.EntityFrameworkCore.Metadata;
//using Microsoft.EntityFrameworkCore.Migrations;
//using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
//namespace Arrestanten_planbord.Data.Migrations
//{
// [DbContext(typeof(ApplicationDbContext))]
// [Migration("00000000000000_CreateIdentitySchema")]
// partial class CreateIdentitySchema
// {
// protected override void BuildTargetModel(ModelBuilder modelBuilder)
// {
//#pragma warning disable 612, 618
// modelBuilder
// .HasAnnotation("ProductVersion", "3.0.0")
// .HasAnnotation("Relational:MaxIdentifierLength", 128)
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
// {
// b.Property<string>("Id")
// .HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
// b.Property<string>("ConcurrencyStamp")
// .IsConcurrencyToken()
// .HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("Name")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
// b.HasIndex("NormalizedName")
// .IsUnique()
// .HasName("RoleNameIndex")
// .HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
// b.ToTable("AspNetRoles");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimType")
// .HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimValue")
// .HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
// b.Property<string>("RoleId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("RoleId");
// b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
// b.ToTable("AspNetRoleClaims");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
// {
// b.Property<string>("Id")
// .HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
// b.Property<int>("AccessFailedCount")
// .HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
// b.Property<string>("ConcurrencyStamp")
// .IsConcurrencyToken()
// .HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("Email")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
// b.Property<bool>("EmailConfirmed")
// .HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
// b.Property<bool>("LockoutEnabled")
// .HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
// b.Property<DateTimeOffset?>("LockoutEnd")
// .HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedEmail")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedUserName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
// b.Property<string>("PasswordHash")
// .HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
// b.Property<string>("PhoneNumber")
// .HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
// b.Property<bool>("PhoneNumberConfirmed")
// .HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
// b.Property<string>("SecurityStamp")
// .HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
// b.Property<bool>("TwoFactorEnabled")
// .HasColumnType("bit");
b.Property<string>("UserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("UserName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
// b.HasIndex("NormalizedEmail")
// .HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
// b.HasIndex("NormalizedUserName")
// .IsUnique()
// .HasName("UserNameIndex")
// .HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
});
// b.ToTable("AspNetUsers");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimType")
// .HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimValue")
// .HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
// b.Property<string>("UserId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("UserId");
// b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
// b.ToTable("AspNetUserClaims");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
// {
// b.Property<string>("LoginProvider")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
// b.Property<string>("ProviderKey")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Name")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
// b.Property<string>("ProviderDisplayName")
// .HasColumnType("nvarchar(max)");
// b.Property<string>("UserId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
// b.HasKey("LoginProvider", "ProviderKey");
// b.HasIndex("UserId");
// b.ToTable("AspNetUserLogins");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
// {
// b.Property<string>("UserId")
// .HasColumnType("nvarchar(450)");
// b.Property<string>("RoleId")
// .HasColumnType("nvarchar(450)");
// b.HasKey("UserId", "RoleId");
// b.HasIndex("RoleId");
// b.ToTable("AspNetUserRoles");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
// {
// b.Property<string>("UserId")
// .HasColumnType("nvarchar(450)");
// b.Property<string>("LoginProvider")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
// b.Property<string>("Name")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
// b.Property<string>("Value")
// .HasColumnType("nvarchar(max)");
// b.HasKey("UserId", "LoginProvider", "Name");
// b.ToTable("AspNetUserTokens");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
// .WithMany()
// .HasForeignKey("RoleId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
// .WithMany()
// .HasForeignKey("RoleId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
//#pragma warning restore 612, 618
// }
// }
//}

View File

@@ -1,220 +1,220 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
//using System;
//using Microsoft.EntityFrameworkCore.Metadata;
//using Microsoft.EntityFrameworkCore.Migrations;
namespace Arrestanten_planbord.Data.Migrations
{
public partial class CreateIdentitySchema : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
//namespace Arrestanten_planbord.Data.Migrations
//{
// public partial class CreateIdentitySchema : Migration
// {
// protected override void Up(MigrationBuilder migrationBuilder)
// {
// migrationBuilder.CreateTable(
// name: "AspNetRoles",
// columns: table => new
// {
// Id = table.Column<string>(nullable: false),
// Name = table.Column<string>(maxLength: 256, nullable: true),
// NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
// ConcurrencyStamp = table.Column<string>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetRoles", x => x.Id);
// });
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
// migrationBuilder.CreateTable(
// name: "AspNetUsers",
// columns: table => new
// {
// Id = table.Column<string>(nullable: false),
// UserName = table.Column<string>(maxLength: 256, nullable: true),
// NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
// Email = table.Column<string>(maxLength: 256, nullable: true),
// NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
// EmailConfirmed = table.Column<bool>(nullable: false),
// PasswordHash = table.Column<string>(nullable: true),
// SecurityStamp = table.Column<string>(nullable: true),
// ConcurrencyStamp = table.Column<string>(nullable: true),
// PhoneNumber = table.Column<string>(nullable: true),
// PhoneNumberConfirmed = table.Column<bool>(nullable: false),
// TwoFactorEnabled = table.Column<bool>(nullable: false),
// LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
// LockoutEnabled = table.Column<bool>(nullable: false),
// AccessFailedCount = table.Column<int>(nullable: false)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetUsers", x => x.Id);
// });
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// migrationBuilder.CreateTable(
// name: "AspNetRoleClaims",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
// RoleId = table.Column<string>(nullable: false),
// ClaimType = table.Column<string>(nullable: true),
// ClaimValue = table.Column<string>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
// table.ForeignKey(
// name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
// column: x => x.RoleId,
// principalTable: "AspNetRoles",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// migrationBuilder.CreateTable(
// name: "AspNetUserClaims",
// columns: table => new
// {
// Id = table.Column<int>(nullable: false)
// .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
// UserId = table.Column<string>(nullable: false),
// ClaimType = table.Column<string>(nullable: true),
// ClaimValue = table.Column<string>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
// table.ForeignKey(
// name: "FK_AspNetUserClaims_AspNetUsers_UserId",
// column: x => x.UserId,
// principalTable: "AspNetUsers",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
ProviderKey = table.Column<string>(maxLength: 128, nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// migrationBuilder.CreateTable(
// name: "AspNetUserLogins",
// columns: table => new
// {
// LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
// ProviderKey = table.Column<string>(maxLength: 128, nullable: false),
// ProviderDisplayName = table.Column<string>(nullable: true),
// UserId = table.Column<string>(nullable: false)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
// table.ForeignKey(
// name: "FK_AspNetUserLogins_AspNetUsers_UserId",
// column: x => x.UserId,
// principalTable: "AspNetUsers",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// migrationBuilder.CreateTable(
// name: "AspNetUserRoles",
// columns: table => new
// {
// UserId = table.Column<string>(nullable: false),
// RoleId = table.Column<string>(nullable: false)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
// table.ForeignKey(
// name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
// column: x => x.RoleId,
// principalTable: "AspNetRoles",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// table.ForeignKey(
// name: "FK_AspNetUserRoles_AspNetUsers_UserId",
// column: x => x.UserId,
// principalTable: "AspNetUsers",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
Name = table.Column<string>(maxLength: 128, nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
// migrationBuilder.CreateTable(
// name: "AspNetUserTokens",
// columns: table => new
// {
// UserId = table.Column<string>(nullable: false),
// LoginProvider = table.Column<string>(maxLength: 128, nullable: false),
// Name = table.Column<string>(maxLength: 128, nullable: false),
// Value = table.Column<string>(nullable: true)
// },
// constraints: table =>
// {
// table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
// table.ForeignKey(
// name: "FK_AspNetUserTokens_AspNetUsers_UserId",
// column: x => x.UserId,
// principalTable: "AspNetUsers",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
// });
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
// migrationBuilder.CreateIndex(
// name: "IX_AspNetRoleClaims_RoleId",
// table: "AspNetRoleClaims",
// column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true,
filter: "[NormalizedName] IS NOT NULL");
// migrationBuilder.CreateIndex(
// name: "RoleNameIndex",
// table: "AspNetRoles",
// column: "NormalizedName",
// unique: true,
// filter: "[NormalizedName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
// migrationBuilder.CreateIndex(
// name: "IX_AspNetUserClaims_UserId",
// table: "AspNetUserClaims",
// column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
// migrationBuilder.CreateIndex(
// name: "IX_AspNetUserLogins_UserId",
// table: "AspNetUserLogins",
// column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
// migrationBuilder.CreateIndex(
// name: "IX_AspNetUserRoles_RoleId",
// table: "AspNetUserRoles",
// column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
// migrationBuilder.CreateIndex(
// name: "EmailIndex",
// table: "AspNetUsers",
// column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
}
// migrationBuilder.CreateIndex(
// name: "UserNameIndex",
// table: "AspNetUsers",
// column: "NormalizedUserName",
// unique: true,
// filter: "[NormalizedUserName] IS NOT NULL");
// }
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
// protected override void Down(MigrationBuilder migrationBuilder)
// {
// migrationBuilder.DropTable(
// name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
// migrationBuilder.DropTable(
// name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
// migrationBuilder.DropTable(
// name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
// migrationBuilder.DropTable(
// name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
// migrationBuilder.DropTable(
// name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
// migrationBuilder.DropTable(
// name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}
// migrationBuilder.DropTable(
// name: "AspNetUsers");
// }
// }
//}

View File

@@ -1,275 +1,275 @@
// <auto-generated />
using System;
using Arrestanten_planbord.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Arrestanten_planbord.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
//// <auto-generated />
//using System;
//using Arrestanten_planbord.Data;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.EntityFrameworkCore.Infrastructure;
//using Microsoft.EntityFrameworkCore.Metadata;
//using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
//namespace Arrestanten_planbord.Data.Migrations
//{
// [DbContext(typeof(ApplicationDbContext))]
// partial class ApplicationDbContextModelSnapshot : ModelSnapshot
// {
// protected override void BuildModel(ModelBuilder modelBuilder)
// {
//#pragma warning disable 612, 618
// modelBuilder
// .HasAnnotation("ProductVersion", "3.0.0")
// .HasAnnotation("Relational:MaxIdentifierLength", 128)
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
// {
// b.Property<string>("Id")
// .HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
// b.Property<string>("ConcurrencyStamp")
// .IsConcurrencyToken()
// .HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("Name")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
// b.HasIndex("NormalizedName")
// .IsUnique()
// .HasName("RoleNameIndex")
// .HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
// b.ToTable("AspNetRoles");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimType")
// .HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimValue")
// .HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
// b.Property<string>("RoleId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("RoleId");
// b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
// b.ToTable("AspNetRoleClaims");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
// {
// b.Property<string>("Id")
// .HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
// b.Property<int>("AccessFailedCount")
// .HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
// b.Property<string>("ConcurrencyStamp")
// .IsConcurrencyToken()
// .HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("Email")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
// b.Property<bool>("EmailConfirmed")
// .HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
// b.Property<bool>("LockoutEnabled")
// .HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
// b.Property<DateTimeOffset?>("LockoutEnd")
// .HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedEmail")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("NormalizedUserName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
// b.Property<string>("PasswordHash")
// .HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
// b.Property<string>("PhoneNumber")
// .HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
// b.Property<bool>("PhoneNumberConfirmed")
// .HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
// b.Property<string>("SecurityStamp")
// .HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
// b.Property<bool>("TwoFactorEnabled")
// .HasColumnType("bit");
b.Property<string>("UserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
// b.Property<string>("UserName")
// .HasColumnType("nvarchar(256)")
// .HasMaxLength(256);
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
// b.HasIndex("NormalizedEmail")
// .HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
// b.HasIndex("NormalizedUserName")
// .IsUnique()
// .HasName("UserNameIndex")
// .HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
});
// b.ToTable("AspNetUsers");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
// {
// b.Property<int>("Id")
// .ValueGeneratedOnAdd()
// .HasColumnType("int")
// .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimType")
// .HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
// b.Property<string>("ClaimValue")
// .HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
// b.Property<string>("UserId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
b.HasKey("Id");
// b.HasKey("Id");
b.HasIndex("UserId");
// b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
// b.ToTable("AspNetUserClaims");
// });
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
// {
// b.Property<string>("LoginProvider")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
// b.Property<string>("ProviderKey")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Name")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
// b.Property<string>("ProviderDisplayName")
// .HasColumnType("nvarchar(max)");
// b.Property<string>("UserId")
// .IsRequired()
// .HasColumnType("nvarchar(450)");
// b.HasKey("LoginProvider", "ProviderKey");
// b.HasIndex("UserId");
// b.ToTable("AspNetUserLogins");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
// {
// b.Property<string>("UserId")
// .HasColumnType("nvarchar(450)");
// b.Property<string>("RoleId")
// .HasColumnType("nvarchar(450)");
// b.HasKey("UserId", "RoleId");
// b.HasIndex("RoleId");
// b.ToTable("AspNetUserRoles");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
// {
// b.Property<string>("UserId")
// .HasColumnType("nvarchar(450)");
// b.Property<string>("LoginProvider")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
// b.Property<string>("Name")
// .HasColumnType("nvarchar(128)")
// .HasMaxLength(128);
// b.Property<string>("Value")
// .HasColumnType("nvarchar(max)");
// b.HasKey("UserId", "LoginProvider", "Name");
// b.ToTable("AspNetUserTokens");
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
// .WithMany()
// .HasForeignKey("RoleId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
// .WithMany()
// .HasForeignKey("RoleId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
// modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
// {
// b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
// .WithMany()
// .HasForeignKey("UserId")
// .OnDelete(DeleteBehavior.Cascade)
// .IsRequired();
// });
//#pragma warning restore 612, 618
// }
// }
//}

View File

@@ -0,0 +1,26 @@
@page "/account/manage"
<h3>Manage</h3>
<div class="container">
<AuthorizeView>
<Authorized>
<p>@context.User.Identity.Name</p>
<p>@context.User.Identity.AuthenticationType</p>
<p>@context.User.Identity.IsAuthenticated</p>
@foreach (var claim in context.User.Claims)
{
<li>@claim.Type &ndash; @claim.Value</li>
}
</Authorized>
<NotAuthorized>
<p> Mag niet </p>
</NotAuthorized>
</AuthorizeView>
</div>
@code {
}

View File

@@ -0,0 +1,6 @@
<h3>Register</h3>
@code {
}

View File

@@ -0,0 +1,90 @@
@page "/account/signin"
@using Microsoft.AspNetCore.Identity
@using System.ComponentModel.DataAnnotations
@using Microsoft.AspNetCore.DataProtection
@using System.Diagnostics
@inject UserManager<IdentityUser> userManager
@inject SignInManager<IdentityUser> signInManager
@inject NavigationManager navigationManager
@inject IDataProtectionProvider dataProtectionProvider
<div class="container">
<h1 class="title">Inloggen</h1>
<EditForm Model="@signInModel" OnValidSubmit="@RegisterUser">
<DataAnnotationsValidator />
<ValidationSummary />
@if (showSignInError)
{
<div class="alert alert-danger" role="alert">
@signInErrorMessage
</div>
}
<div class="form-group">
<label for="name">Naam</label>
<InputText id="name" class="form-control" type="text" @bind-Value="@signInModel.Name"></InputText>
</div>
<div class="form-group">
<label for="Password">Paswoord</label>
<InputText id="password" class="form-control" type="password" @bind-Value="@signInModel.Password"></InputText>
</div>
<div class="form-check">
<InputCheckbox id="rememberMe" class="form-check-input" type="checkbox" @bind-Value="@signInModel.RememberMe"></InputCheckbox>
<label class="form-check-label" for="rememberMe">Ingelogd blijven</label>
</div>
<br />
<div class="form-group">
<button type="submit" class="btn btn-primary">Inloggen</button>
</div>
</EditForm>
</div>
@code {
private SignInModel signInModel = new SignInModel();
private bool showSignInError = false;
private string signInErrorMessage;
private async Task RegisterUser()
{
showSignInError = false;
var user = await userManager.FindByNameAsync(signInModel.Name);
if (user != null && await userManager.CheckPasswordAsync(user, signInModel.Password))
{
var token = await userManager.GenerateUserTokenAsync(user, TokenOptions.DefaultProvider, "SignIn");
var data = $"{user.Id}|{token}|{signInModel.RememberMe}";
//Debug.WriteLine(data);
var protector = dataProtectionProvider.CreateProtector("SignIn");
var pdata = protector.Protect(data);
navigationManager.NavigateTo("/account/signinactual?t=" + pdata, forceLoad: true);
}
else
{
signInErrorMessage = "Sorry, verkeerde naam of paswoord";
showSignInError = true;
}
}
public class SignInModel
{
[Required(ErrorMessage = "Geen naam opgegeven")]
public string Name { get; set; }
[Required(ErrorMessage = "Geen paswoord opgegeven")]
[DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
}

View File

@@ -0,0 +1,81 @@
@page "/userlist"
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@inject AuthenticationStateProvider authenticationStateProvider
<h3>UserList</h3>
<div class="container">
<table class="table table-bordered table-striped table-dark table-sm ComponetTable">
<thead>
<tr>
<th colspan="3">
Users
</th>
</tr>
</thead>
<tbody>
@*@for (int i = 0; i < TotalLines; i++)
{
var a = i; //convert i to local var
<tr>
<th scope="row" class="col-1 py-2px">@(i + 1)</th>
<td class="py-2px">@DoctorData.Lines[i]</td>
<td class="col-1 py-2px">
<div class="d-flex justify-content-end">
<div class="p2"><img class="ClickableImage" src="./icons/edit32.png" height="18" @onclick="(() => ShowModal(a))"></div>
</div>
</td>
</tr>
}*@
</tbody>
</table>
</div>
<div class="container">
<h3>ClaimsPrincipal Data</h3>
<button @onclick="GetClaimsPrincipalData">Get ClaimsPrincipal Data</button>
<p>@_authMessage</p>
@if (_claims.Count() > 0)
{
<ul>
@foreach (var claim in _claims)
{
<li>@claim.Type &ndash; @claim.Value</li>
}
</ul>
}
<p>@_surnameMessage</p>
</div>
@code {
private string _authMessage;
private string _surnameMessage;
private IEnumerable<Claim> _claims = Enumerable.Empty<Claim>();
private async Task GetClaimsPrincipalData()
{
var authState = await authenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
_authMessage = $"{user.Identity.Name} is authenticated.";
_claims = user.Claims;
_surnameMessage = $"Surname: {user.FindFirst(c => c.Type == ClaimTypes.Surname)?.Value}";
}
else
{
_authMessage = "The user is NOT authenticated.";
}
}
}

View File

@@ -1,8 +1,9 @@
@using Microsoft.AspNetCore.Hosting
@*@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
<!DOCTYPE html>
@inject ICompositeViewEngine Engine*@
<!-- _Layout.cshtml -->
@*<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
@@ -55,4 +56,5 @@
<script src="~/Identity/js/site.js" asp-append-version="true"></script>
@RenderSection("Scripts", required: false)
</body>
</html>
</html>*@
<!-- End _Layout.cshtml -->

View File

@@ -2,26 +2,27 @@
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a id="manage" class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @UserManager.GetUserName(User)!</a>
</li>
<li class="nav-item">
<form id="logoutForm" class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/Index", new { area = "" })">
<button id="logout" type="submit" class="nav-link btn btn-link text-dark">Logout</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" id="register" asp-area="Identity" asp-page="/Account/Register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" id="login" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>
}
</ul>
<!-- _LoginPartial.cshtml -->
@*<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a id="manage" class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @UserManager.GetUserName(User)!</a>
</li>
<li class="nav-item">
<form id="logoutForm" class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/Index", new { area = "" })">
<button id="logout" type="submit" class="nav-link btn btn-link text-dark">Logout</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" id="register" asp-area="Identity" asp-page="/Account/Register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" id="login" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>
}
</ul>*@
<!-- End _LoginPartial.cshtml -->

View File

@@ -1,4 +1,4 @@
<environment include="Development">
@*<environment include="Development">
<script src="~/Identity/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/Identity/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
</environment>
@@ -15,4 +15,4 @@
crossorigin="anonymous"
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
</script>
</environment>
</environment>*@

View File

@@ -30,7 +30,7 @@
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<!-- inside of body section and after the <app> tag -->
<script src="~/js/jquery-3.3.1.slim.min.js"></script>
<script src="~/js/popper.min.js"></script>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>7af41af4-365c-4997-a3b2-96e9e0845443</ProjectGuid>
<publishUrl>bin\publish\IIS Win-x64</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>

View File

@@ -1,12 +1,13 @@
<AuthorizeView>
<Authorized>
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
<form method="post" action="Identity/Account/LogOut">
@*<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>*@
@*<a href="Identity/Manage">Hallo, @context.User.Identity.Name!</a>*@
@*<form method="post" action="Identity/Account/LogOut">
<button type="submit" class="nav-link btn btn-link">Log out</button>
</form>
</form>*@
</Authorized>
<NotAuthorized>
<a href="Identity/Account/Register">Register</a>
<a href="Identity/Account/Login">Log in</a>
@*<a href="Identity/Account/Register">Register</a>
<a href="Identity/Account/Login">Log in</a>*@
</NotAuthorized>
</AuthorizeView>

View File

@@ -1,6 +1,6 @@
@inherits LayoutComponentBase
<!--MainLayout.razor -->
<!--MainLayout.razor -->
<RadzenDialog />
<RadzenNotification />
@@ -10,12 +10,30 @@
<div class="main">
<div class="top-row px-4 auth">
<LoginDisplay />
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
@*<LoginDisplay />*@
<AuthorizeView>
<Authorized>
<a href="/account/manage" class="nav-link btn btn-link">Hallo, @context.User.Identity.Name!</a>
<a href="/account/signout" class="nav-link btn btn-link">Uitloggen</a>
</Authorized>
<NotAuthorized>
<a href="/account/signin" class="nav-link btn btn-link" >Inloggen</a>
</NotAuthorized>
</AuthorizeView>
</div>
<div class="content px-4">
@Body
<AuthorizeView>
<Authorized>
@Body
</Authorized>
<NotAuthorized>
<Arrestanten_planbord.Pages.Account.SignIn></Arrestanten_planbord.Pages.Account.SignIn>
</NotAuthorized>
</AuthorizeView>
</div>
</div>
<!-- End MainLayout.razor -->
@code {
}

View File

@@ -5,6 +5,7 @@
</button>
</div>
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
@@ -12,20 +13,37 @@
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</li>
<AuthorizeView>
<li class="nav-item px-3">
<NavLink class="nav-link" href="/Eindhoven">
<span class="oi oi-list-rich" aria-hidden="true"></span> Eindhoven
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="Eindhoven">
<span class="oi oi-list-rich" aria-hidden="true"></span> Eindhoven
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="/RadzenModal">
<span class="oi oi-list-rich" aria-hidden="true"></span> radzen Modal
</NavLink>
</li>
</AuthorizeView>
<AuthorizeView Roles="admin">
<li class="nav-item px-3">
<NavLink class="nav-link" href="userlist">
<span class="oi oi-list-rich" aria-hidden="true"></span> Admin menu
</NavLink>
</li>
</AuthorizeView>
<li class="nav-item px-3">
<NavLink class="nav-link" href="RadzenModal">
<span class="oi oi-list-rich" aria-hidden="true"></span> radzen Modal
</NavLink>
</li>
</ul>
<AuthorizeView>
<li class="nav-item px-3">
<NavLink class="nav-link" href="userlist">
<span class="oi oi-list-rich" aria-hidden="true"></span> User list
</NavLink>
</li>
</AuthorizeView>
</ul>
</div>

View File

@@ -39,8 +39,6 @@ namespace Arrestanten_planbord
// options.UseSqlServer(
// Configuration.GetConnectionString("DefaultConnection")));
//services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
// .AddEntityFrameworkStores<ApplicationDbContext>();
@@ -53,8 +51,9 @@ namespace Arrestanten_planbord
options.Password.RequireUppercase = false;
options.Password.RequireLowercase = false;
})
.AddUserStore<Areas.Identity.Data.CustomUserStore>();
.AddUserStore<CustomUserStore>();
//.AddUserStore<Areas.Identity.Data.CustomUserStore>();
//services.AddAuthenticationCore();
services.AddRazorPages();
services.AddServerSideBlazor();
@@ -85,13 +84,13 @@ namespace Arrestanten_planbord
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
//app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
//app.UseHsts();
}
app.UseStaticFiles();

11
README Normal file
View File

@@ -0,0 +1,11 @@
- Install to iis
https://dotnetcoretutorials.com/2019/12/23/hosting-an-asp-net-core-web-application-in-iis/
Self contained .NET Core applications on IIS still need the ASP.NET Core hosting bundle
-Install ASP>NET Core Runtime Ver
windows Hosting Bundle
- restart server