Add ApplicationUser entity.

This commit is contained in:
2019-05-27 03:00:04 +01:00
parent 5a1010ca3a
commit 9a1e00cbee
4 changed files with 42 additions and 14 deletions

View File

@@ -0,0 +1,6 @@
using Microsoft.AspNetCore.Identity;
namespace Cicm.Database.Models
{
public class ApplicationUser : IdentityUser { }
}

View File

@@ -31,7 +31,6 @@
using Cicm.Database.Models; using Cicm.Database.Models;
using cicm_web.Areas.Identity; using cicm_web.Areas.Identity;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
[assembly: HostingStartup(typeof(IdentityHostingStartup))] [assembly: HostingStartup(typeof(IdentityHostingStartup))]
@@ -44,7 +43,7 @@ namespace cicm_web.Areas.Identity
{ {
builder.ConfigureServices((context, services) => builder.ConfigureServices((context, services) =>
{ {
services.AddDefaultIdentity<IdentityUser>() services.AddDefaultIdentity<ApplicationUser>()
.AddEntityFrameworkStores<cicmContext>(); .AddEntityFrameworkStores<cicmContext>();
}); });
} }

View File

@@ -1,7 +1,8 @@
@using Cicm.Database.Models
@using Microsoft.AspNetCore.Identity @using Microsoft.AspNetCore.Identity
@using Microsoft.Extensions.PlatformAbstractions @using Microsoft.Extensions.PlatformAbstractions
@inject SignInManager<IdentityUser> SignInManager @inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<IdentityUser> UserManager @inject UserManager<ApplicationUser> UserManager
@{ @{
/****************************************************************************** /******************************************************************************
// Canary Islands Computer Museum Website // Canary Islands Computer Museum Website

View File

@@ -1,6 +1,7 @@
@using Cicm.Database.Models
@using Microsoft.AspNetCore.Identity @using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager @inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<IdentityUser> UserManager @inject UserManager<ApplicationUser> UserManager
@{ @{
/****************************************************************************** /******************************************************************************
// Canary Islands Computer Museum Website // Canary Islands Computer Museum Website
@@ -35,13 +36,26 @@
@if(SignInManager.IsSignedIn(User)) @if(SignInManager.IsSignedIn(User))
{ {
<form asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/Index", new { area = "" })" method="post" id="logoutForm" class="navbar-right"> <form asp-area="Identity"
asp-page="/Account/Logout"
asp-route-returnUrl="@Url.Page("/Index", new {area = ""})"
method="post"
id="logoutForm"
class="navbar-right">
<ul class="ml-auto navbar-nav"> <ul class="ml-auto navbar-nav">
<li> <li>
<a asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage" class=nav-link>Hello @UserManager.GetUserName(User)!</a> <a asp-area="Identity"
asp-page="/Account/Manage/Index"
class=nav-link
title="Manage">
Hello @UserManager.GetUserName(User)!
</a>
</li> </li>
<li> <li>
<button type="submit" class="btn btn-link nav-link">Logout</button> <button class="btn btn-link nav-link"
type="submit">
Logout
</button>
</li> </li>
</ul> </ul>
</form> </form>
@@ -61,8 +75,16 @@ else
</a> </a>
<div aria-labelledby=accountDropdown <div aria-labelledby=accountDropdown
class=dropdown-menu> class=dropdown-menu>
<a asp-area="Identity" asp-page="/Account/Register" class=dropdown-item>Register</a> <a asp-area="Identity"
<a asp-area="Identity" asp-page="/Account/Login" class=dropdown-item>Login</a> asp-page="/Account/Register"
class=dropdown-item>
Register
</a>
<a asp-area="Identity"
asp-page="/Account/Login"
class=dropdown-item>
Login
</a>
</div> </div>
</ul> </ul>
} }