Skip to content

Commit e574e06

Browse files
committed
Updated IdentityServerHost namespaces and added new views
Updated the `Microsoft.VisualStudio.Web.CodeGeneration.Design` package version and changed namespaces in several files from `IdentityServerHost.Quickstart.UI` to `Identity.API`. Added a new private field and updated methods in `AccountController.cs`. Updated classes in `RegisterViewModel.cs` and `ErrorViewModel.cs`. Added `RegisterViewModelsController.cs` and updated several .cshtml files. Removed several files from the `IdentityServerHost.Quickstart.UI` namespace. Added new views for device authorization flow, CRUD operations on `RegisterViewModel`, and handling errors and redirects. Updated `_Layout.cshtml` and added new partial views. Updated `using` directives in `_ViewImports.cshtml`.
1 parent 5f14d48 commit e574e06

File tree

71 files changed

+649
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+649
-172
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<!-- VS Test -->
7373
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
7474
<!-- Scaffolding -->
75-
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0-rc.1.23461.3" />
75+
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
7676
<!-- Grpc -->
7777
<PackageVersion Include="Grpc.AspNetCore" Version="$(GrpcVersion)" />
7878
<PackageVersion Include="Grpc.AspNetCore.Server.ClientFactory" Version="$(GrpcVersion)" />

Identity.API/Quickstart/Account/AccountController.cs renamed to Identity.API/Controllers/AccountController.cs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
namespace IdentityServerHost.Quickstart.UI;
5-
4+
namespace Identity.API.Controllers;
65
using eShop.Identity.API.Models.AccountViewModels;
6+
using Identity.API.Models.Account;
77

88
[SecurityHeaders]
99
[AllowAnonymous]
@@ -16,6 +16,7 @@ public class AccountController : Controller
1616
private readonly IAuthenticationSchemeProvider _schemeProvider;
1717
private readonly IAuthenticationHandlerProvider _handlerProvider;
1818
private readonly IEventService _events;
19+
private readonly ApplicationDbContext _context;
1920

2021
public AccountController(
2122
UserManager<ApplicationUser> userManager,
@@ -24,7 +25,8 @@ public AccountController(
2425
IClientStore clientStore,
2526
IAuthenticationSchemeProvider schemeProvider,
2627
IAuthenticationHandlerProvider handlerProvider,
27-
IEventService events)
28+
IEventService events,
29+
ApplicationDbContext context)
2830
{
2931
_userManager = userManager;
3032
_signInManager = signInManager;
@@ -33,6 +35,7 @@ public AccountController(
3335
_schemeProvider = schemeProvider;
3436
_handlerProvider = handlerProvider;
3537
_events = events;
38+
_context = context;
3639
}
3740

3841
[HttpGet]
@@ -43,11 +46,27 @@ public IActionResult Register()
4346

4447
[HttpPost]
4548
[ValidateAntiForgeryToken]
46-
public async Task<IActionResult> Register(RegisterViewModel model)
49+
public async Task<IActionResult> RegisterCreate(RegisterViewModel model)
4750
{
4851
if (ModelState.IsValid)
4952
{
50-
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
53+
var user = new ApplicationUser
54+
{
55+
UserName = model.Email,
56+
Email = model.Email,
57+
CardNumber = model.CardNumber,
58+
SecurityNumber = model.SecurityNumber,
59+
Expiration = model.Expiration,
60+
CardHolderName = model.CardHolderName,
61+
CardType = model.CardType,
62+
Street = model.Street,
63+
City = model.City,
64+
State = model.State,
65+
Country = model.Country,
66+
ZipCode = model.ZipCode,
67+
Name = model.Name,
68+
LastName = model.LastName
69+
};
5170
var result = await _userManager.CreateAsync(user, model.Password);
5271
if (result.Succeeded)
5372
{
@@ -64,6 +83,19 @@ public async Task<IActionResult> Register(RegisterViewModel model)
6483
return View(model);
6584
}
6685

86+
//[HttpPost]
87+
//[ValidateAntiForgeryToken]
88+
//public async Task<IActionResult> RegisterCreate([Bind("Id,Email,Password,ConfirmPassword")] RegisterViewModel registerViewModel)
89+
//{
90+
// if (ModelState.IsValid)
91+
// {
92+
// _context.Add(registerViewModel);
93+
// await _context.SaveChangesAsync();
94+
// return RedirectToAction(nameof(Index));
95+
// }
96+
// return View(registerViewModel);
97+
//}
98+
6799
/// <summary>
68100
/// Entry point into the login workflow
69101
/// </summary>
@@ -215,7 +247,7 @@ public async Task<IActionResult> Logout(LogoutInputModel model)
215247
// build a return URL so the upstream provider will redirect back
216248
// to us after the user has logged out. this allows us to then
217249
// complete our single sign-out processing.
218-
string url = Url.Action("Logout", new { logoutId = vm.LogoutId });
250+
var url = Url.Action("Logout", new { logoutId = vm.LogoutId });
219251

220252
// this triggers a redirect to the external provider for sign-out
221253
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);

Identity.API/Quickstart/Account/AccountOptions.cs renamed to Identity.API/Controllers/AccountOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
namespace IdentityServerHost.Quickstart.UI;
4+
namespace Identity.API.Controllers;
55

66
public class AccountOptions
77
{

Identity.API/Quickstart/Consent/ConsentController.cs renamed to Identity.API/Controllers/ConsentController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
namespace IdentityServerHost.Quickstart.UI;
4+
namespace Identity.API.Controllers;
5+
6+
using Identity.API.Models.Consent;
57

68
/// <summary>
79
/// This controller processes the consent UI

Identity.API/Quickstart/Consent/ConsentOptions.cs renamed to Identity.API/Controllers/ConsentOptions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
5-
namespace IdentityServerHost.Quickstart.UI;
4+
namespace Identity.API.Controllers;
65

76
public class ConsentOptions
87
{

Identity.API/Quickstart/Device/DeviceController.cs renamed to Identity.API/Controllers/DeviceController.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
namespace IdentityServerHost.Quickstart.UI;
4+
namespace Identity.API.Controllers;
5+
6+
using Identity.API.Models.Consent;
7+
using Identity.API.Models.Device;
58

69
[Authorize]
710
[SecurityHeaders]
@@ -27,7 +30,7 @@ public DeviceController(
2730
[HttpGet]
2831
public async Task<IActionResult> Index()
2932
{
30-
string userCodeParamName = _options.Value.UserInteraction.DeviceVerificationUserCodeParameter;
33+
var userCodeParamName = _options.Value.UserInteraction.DeviceVerificationUserCodeParameter;
3134
string userCode = Request.Query[userCodeParamName];
3235
if (string.IsNullOrWhiteSpace(userCode)) return View("UserCodeCapture");
3336

Identity.API/Quickstart/Diagnostics/DiagnosticsController.cs renamed to Identity.API/Controllers/DiagnosticsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44

5-
namespace IdentityServerHost.Quickstart.UI;
5+
namespace Identity.API.Controllers;
6+
using Identity.API.Models;
67

78
[SecurityHeaders]
89
[Authorize]
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace IdentityServerHost.Quickstart.UI;
1+
namespace Identity.API.Controllers;
2+
3+
using Identity.API.Models.Account;
24

35
public static class Extensions
46
{

Identity.API/Quickstart/Account/ExternalController.cs renamed to Identity.API/Controllers/ExternalController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
namespace IdentityServerHost.Quickstart.UI;
2-
1+
namespace Identity.API.Controllers;
32
[SecurityHeaders]
43
[AllowAnonymous]
54
public class ExternalController : Controller

Identity.API/Quickstart/Account/ExternalProvider.cs renamed to Identity.API/Controllers/ExternalProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
1+
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

4-
namespace IdentityServerHost.Quickstart.UI;
4+
namespace Identity.API.Controllers;
55

66
public class ExternalProvider
77
{

0 commit comments

Comments
 (0)