Skip to content

Commit

Permalink
Remove Obsolete External Authentication settings (#17049)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek authored Nov 23, 2024
1 parent 4342f04 commit 3421e74
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using OrchardCore.Mvc.Core.Utilities;
using OrchardCore.Settings;
using OrchardCore.Users.Events;
using OrchardCore.Users.Handlers;
using OrchardCore.Users.Models;
using OrchardCore.Users.Services;
using OrchardCore.Users.ViewModels;
Expand All @@ -23,9 +22,6 @@ namespace OrchardCore.Users.Controllers;
[Authorize]
public sealed class AccountController : AccountBaseController
{
[Obsolete("This property is no longer used and will be removed in v3.")]
public const string DefaultExternalLoginProtector = "DefaultExternalLogin";

private readonly IUserService _userService;
private readonly SignInManager<IUser> _signInManager;
private readonly UserManager<IUser> _userManager;
Expand Down Expand Up @@ -69,7 +65,6 @@ public AccountController(
S = stringLocalizer;
}

[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> Login(string returnUrl = null)
{
Expand Down Expand Up @@ -196,7 +191,6 @@ public async Task<IActionResult> LogOff(string returnUrl = null)
return RedirectToLocal(returnUrl);
}

[HttpGet]
public IActionResult ChangePassword(string returnUrl = null)
{
ViewData["ReturnUrl"] = returnUrl;
Expand Down Expand Up @@ -231,22 +225,6 @@ public async Task<IActionResult> ChangePassword(ChangePasswordViewModel model, s
public IActionResult ChangePasswordConfirmation()
=> View();

/// <summary>
/// This action is retained for backward compatibility.
/// Both this action and <see cref="ExternalAuthenticationsStartupFilter"/> are scheduled for removal in version 3.
/// </summary>
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public IActionResult ExternalLogin()
{
return NotFound();
}

[Obsolete("This method will be removed in version 3. Instead please use UserManagerHelper.UpdateUserPropertiesAsync(userManager, user, context).")]
public static Task<bool> UpdateUserPropertiesAsync(UserManager<IUser> userManager, User user, UpdateUserContext context)
=> UserManagerHelper.UpdateUserPropertiesAsync(userManager, user, context);

private async Task<bool> AddConfirmEmailErrorAsync(IUser user)
{
if (_registrationOptions.UsersMustValidateEmail)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ public async Task<ActionResult> Index([ModelBinder(BinderType = typeof(UserFilte

options.UserFilters =
[
new SelectListItem() { Text = S["All Users"], Value = nameof(UsersFilter.All), Selected = (options.Filter == UsersFilter.All) },
new SelectListItem() { Text = S["Enabled Users"], Value = nameof(UsersFilter.Enabled), Selected = (options.Filter == UsersFilter.Enabled) },
new SelectListItem() { Text = S["Disabled Users"], Value = nameof(UsersFilter.Disabled), Selected = (options.Filter == UsersFilter.Disabled) }
new SelectListItem() { Text = S["All Users"], Value = nameof(UsersFilter.All), Selected = options.Filter == UsersFilter.All },
new SelectListItem() { Text = S["Enabled Users"], Value = nameof(UsersFilter.Enabled), Selected = options.Filter == UsersFilter.Enabled },
new SelectListItem() { Text = S["Disabled Users"], Value = nameof(UsersFilter.Disabled), Selected = options.Filter == UsersFilter.Disabled }
// new SelectListItem() { Text = S["Approved"], Value = nameof(UsersFilter.Approved) },
// new SelectListItem() { Text = S["Email pending"], Value = nameof(UsersFilter.EmailPending) },
// new SelectListItem() { Text = S["Pending"], Value = nameof(UsersFilter.Pending) }
];

options.UserSorts =
[
new SelectListItem() { Text = S["Name"], Value = nameof(UsersOrder.Name), Selected = (options.Order == UsersOrder.Name) },
new SelectListItem() { Text = S["Email"], Value = nameof(UsersOrder.Email), Selected = (options.Order == UsersOrder.Email) },
new SelectListItem() { Text = S["Name"], Value = nameof(UsersOrder.Name), Selected = options.Order == UsersOrder.Name },
new SelectListItem() { Text = S["Email"], Value = nameof(UsersOrder.Email), Selected = options.Order == UsersOrder.Email },
// new SelectListItem() { Text = S["Created date"], Value = nameof(UsersOrder.CreatedUtc) },
// new SelectListItem() { Text = S["Last Login date"], Value = nameof(UsersOrder.LastLoginUtc) }
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@ namespace OrchardCore.Users.Models;

public class RegistrationSettings
{
[Obsolete("This property is no longer used and will be removed in the next major release.")]
public UserRegistrationType UsersCanRegister { get; set; }

public bool UsersMustValidateEmail { get; set; }

public bool UsersAreModerated { get; set; }

public bool UseSiteTheme { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalRegistrationSettings.NoPassword")]
public bool NoPasswordForExternalUsers { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalRegistrationSettings.NoUsername")]
public bool NoUsernameForExternalUsers { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalRegistrationSettings.NoEmail")]
public bool NoEmailForExternalUsers { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalRegistrationSettings.UseScriptToGenerateUsername")]
public bool UseScriptToGenerateUsername { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalRegistrationSettings.GenerateUsernameScript")]
public string GenerateUsernameScript { get; set; }
}

This file was deleted.

1 change: 0 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Users/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public override void ConfigureServices(IServiceCollection services)
// This is required for security modules like the OpenID module (that uses SignOutAsync()) to work correctly.
services.AddAuthentication(options => options.DefaultSignOutScheme = IdentityConstants.ApplicationScheme);

services.AddSingleton<Microsoft.AspNetCore.Hosting.IStartupFilter, ExternalAuthenticationsStartupFilter>();
services.AddUsers();

services.ConfigureApplicationCookie(options =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@ public class LoginSettings
{
public bool UseSiteTheme { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalLoginSettings.UseExternalProviderIfOnlyOneDefined")]
public bool UseExternalProviderIfOnlyOneDefined { get; set; }

public bool DisableLocalLogin { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalLoginSettings.UseScriptToSyncProperties")]
public bool UseScriptToSyncRoles { get; set; }

[Obsolete("This property is no longer used and will be removed in the next major release. Instead use ExternalLoginSettings.SyncPropertiesScript")]
public string SyncRolesScript { get; set; }

public bool AllowChangingUsername { get; set; }

public bool AllowChangingEmail { get; set; }
Expand Down
25 changes: 25 additions & 0 deletions src/docs/releases/3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Release date: Not yet released

Before upgrading from version 2 to v3, it is important to first compile your project using the latest available v2 version, resolve any warnings, and then proceed with the upgrade to v3.

## Breaking Changes

### GraphQL Module
Expand All @@ -23,3 +25,26 @@ The `GraphQL` libraries have been upgraded from version 7 to version 8. Below ar
- All implementations of `IContentTypeBuilder`
- All implementations of `GraphQLFilter`
- All implementations of `ISchemaBuilder`

### Users Module

#### Removed old settings

The following obsolete settings were removed from `RegistrationSettings` class

- `NoPasswordForExternalUsers`
- `NoUsernameForExternalUsers`
- `NoEmailForExternalUsers`
- `UseScriptToGenerateUsername`
- `GenerateUsernameScript`
- `UsersCanRegister`

The following obsolete settings were removed from `LoginSettings` class

- `UseExternalProviderIfOnlyOneDefined`
- `UseScriptToSyncRoles`
- `SyncRolesScript`

#### Login View Update

The `ExternalLogin` action has been removed from the `Account` controller. If you are using a custom `Login.cshtml` view or `Login` template, please update the external login form action. As of this update, the `ExternalLogin` action has been relocated to the `ExternalAuthentications` controller.

0 comments on commit 3421e74

Please sign in to comment.