Files
Umbraco-CMS/src/Umbraco.Web.BackOffice/Controllers/BackOfficeController.cs

647 lines
27 KiB
C#
Raw Normal View History

using System.Globalization;
using System.Net;
using System.Security.Claims;
using System.Security.Principal;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Grid;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Manifest;
using Umbraco.Cms.Core.Security;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.WebAssets;
using Umbraco.Cms.Infrastructure.WebAssets;
using Umbraco.Cms.Web.BackOffice.ActionResults;
using Umbraco.Cms.Web.BackOffice.Filters;
using Umbraco.Cms.Web.BackOffice.Install;
using Umbraco.Cms.Web.BackOffice.Security;
2021-02-10 11:42:04 +01:00
using Umbraco.Cms.Web.Common.ActionsResults;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Extensions;
using SignInResult = Microsoft.AspNetCore.Identity.SignInResult;
namespace Umbraco.Cms.Web.BackOffice.Controllers;
[DisableBrowserCache]
[UmbracoRequireHttps]
[PluginController(Constants.Web.Mvc.BackOfficeArea)]
[IsBackOffice]
public class BackOfficeController : UmbracoController
{
private readonly AppCaches _appCaches;
private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor;
private readonly BackOfficeServerVariables _backOfficeServerVariables;
private readonly IBackOfficeTwoFactorOptions _backOfficeTwoFactorOptions;
private readonly IBackOfficeExternalLoginProviders _externalLogins;
private readonly IGridConfig _gridConfig;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger<BackOfficeController> _logger;
private readonly IManifestParser _manifestParser;
private readonly IRuntimeMinifier _runtimeMinifier;
private readonly IRuntimeState _runtimeState;
private readonly IOptions<SecuritySettings> _securitySettings;
private readonly ServerVariablesParser _serverVariables;
private readonly IBackOfficeSignInManager _signInManager;
private readonly ILocalizedTextService _textService;
// See here for examples of what a lot of this is doing: https://github.com/dotnet/aspnetcore/blob/main/src/Identity/samples/IdentitySample.Mvc/Controllers/AccountController.cs
// along with our AuthenticationController
// NOTE: Each action must either be explicitly authorized or explicitly [AllowAnonymous], the latter is optional because
// this controller itself doesn't require authz but it's more clear what the intention is.
private readonly IBackOfficeUserManager _userManager;
private readonly GlobalSettings _globalSettings;
[ActivatorUtilitiesConstructor]
public BackOfficeController(
IBackOfficeUserManager userManager,
IRuntimeState runtimeState,
IRuntimeMinifier runtimeMinifier,
IOptionsSnapshot<GlobalSettings> globalSettings,
IHostingEnvironment hostingEnvironment,
ILocalizedTextService textService,
IGridConfig gridConfig,
BackOfficeServerVariables backOfficeServerVariables,
AppCaches appCaches,
IBackOfficeSignInManager signInManager,
IBackOfficeSecurityAccessor backofficeSecurityAccessor,
ILogger<BackOfficeController> logger,
IJsonSerializer jsonSerializer,
IBackOfficeExternalLoginProviders externalLogins,
IHttpContextAccessor httpContextAccessor,
IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions,
IManifestParser manifestParser,
ServerVariablesParser serverVariables,
IOptions<SecuritySettings> securitySettings)
{
_userManager = userManager;
_runtimeState = runtimeState;
_runtimeMinifier = runtimeMinifier;
_globalSettings = globalSettings.Value;
_hostingEnvironment = hostingEnvironment;
_textService = textService;
_gridConfig = gridConfig ?? throw new ArgumentNullException(nameof(gridConfig));
_backOfficeServerVariables = backOfficeServerVariables;
_appCaches = appCaches;
_signInManager = signInManager;
_backofficeSecurityAccessor = backofficeSecurityAccessor;
_logger = logger;
_jsonSerializer = jsonSerializer;
_externalLogins = externalLogins;
_httpContextAccessor = httpContextAccessor;
_backOfficeTwoFactorOptions = backOfficeTwoFactorOptions;
_manifestParser = manifestParser;
_serverVariables = serverVariables;
_securitySettings = securitySettings;
}
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> Default()
{
// Check if we not are in an run state, if so we need to redirect
if (_runtimeState.Level != RuntimeLevel.Run)
{
if (_runtimeState.Level == RuntimeLevel.Upgrade)
{
return RedirectToAction(nameof(AuthorizeUpgrade), routeValues: new RouteValueDictionary()
{
["redir"] = _globalSettings.GetBackOfficePath(_hostingEnvironment),
});
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLocal(null);
}
// force authentication to occur since this is not an authorized endpoint
AuthenticateResult result = await this.AuthenticateBackOfficeAsync();
2021-07-26 16:55:41 -06:00
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// if we are not authenticated then we need to redirect to the login page
if (!result.Succeeded)
{
return RedirectToLogin(null);
}
ViewResult defaultView = DefaultView();
return await RenderDefaultOrProcessExternalLoginAsync(
result,
() => defaultView);
}
/// <summary>
/// Returns the default view for the BackOffice
/// </summary>
/// <returns>The default view currently /umbraco/UmbracoBackOffice/Default.cshtml</returns>
public ViewResult DefaultView()
{
var viewPath = Path.Combine(Constants.SystemDirectories.Umbraco, Constants.Web.Mvc.BackOfficeArea, nameof(Default) + ".cshtml")
.Replace("\\", "/"); // convert to forward slashes since it's a virtual path
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return View(viewPath);
}
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> Login()
{
// force authentication to occur since this is not an authorized endpoint
AuthenticateResult result = await this.AuthenticateBackOfficeAsync();
var viewPath = Path.Combine(Constants.SystemDirectories.Umbraco, Constants.Web.Mvc.BackOfficeLoginArea, "Index.cshtml")
.Replace("\\", "/"); // convert to forward slashes since it's a virtual path
return await RenderDefaultOrProcessExternalLoginAsync(
result,
() => View(viewPath));
}
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> VerifyInvite(string invite)
{
AuthenticateResult authenticate = await this.AuthenticateBackOfficeAsync();
//if you are hitting VerifyInvite, you're already signed in as a different user, and the token is invalid
//you'll exit on one of the return RedirectToAction(nameof(Default)) but you're still logged in so you just get
//dumped at the default admin view with no detail
if (authenticate.Succeeded)
{
await _signInManager.SignOutAsync();
}
if (invite == null)
{
_logger.LogWarning("VerifyUser endpoint reached with invalid token: NULL");
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", status = "invalidToken" });
}
var parts = WebUtility.UrlDecode(invite).Split('|');
if (parts.Length != 2)
{
_logger.LogWarning("VerifyUser endpoint reached with invalid token: {Invite}", invite);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", status = "invalidToken" });
}
var token = parts[1];
var decoded = token.FromUrlBase64();
if (decoded.IsNullOrWhiteSpace())
{
_logger.LogWarning("VerifyUser endpoint reached with invalid token: {Invite}", invite);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", status = "invalidToken" });
}
var id = parts[0];
BackOfficeIdentityUser? identityUser = await _userManager.FindByIdAsync(id);
if (identityUser == null)
{
_logger.LogWarning("VerifyUser endpoint reached with non existing user: {UserId}", id);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", status = "nonExistingUser" });
}
IdentityResult result = await _userManager.ConfirmEmailAsync(identityUser, decoded!);
if (result.Succeeded == false)
{
_logger.LogWarning("Could not verify email, Error: {Errors}, Token: {Invite}", result.Errors.ToErrorMessage(), invite);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", status = "false", invite = "3" });
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// sign the user in
DateTime? previousLastLoginDate = identityUser.LastLoginDateUtc;
await _signInManager.SignInAsync(identityUser, false);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// reset the lastlogindate back to previous as the user hasn't actually logged in, to add a flag or similar to BackOfficeSignInManager would be a breaking change
identityUser.LastLoginDateUtc = previousLastLoginDate;
await _userManager.UpdateAsync(identityUser);
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "invite-user", invite = "1" });
}
/// <summary>
/// This Action is used by the installer when an upgrade is detected but the admin user is not logged in. We need to
/// ensure the user is authenticated before the install takes place so we redirect here to show the standard login
/// screen.
/// </summary>
/// <returns></returns>
[HttpGet]
[StatusCodeResult(HttpStatusCode.ServiceUnavailable)]
[AllowAnonymous]
public async Task<IActionResult> AuthorizeUpgrade()
{
// force authentication to occur since this is not an authorized endpoint
AuthenticateResult result = await this.AuthenticateBackOfficeAsync();
if (result.Succeeded)
{
// Redirect to installer if we're already authorized
var installerUrl = Url.Action(nameof(InstallController.Index), ControllerExtensions.GetControllerName<InstallController>(), new { area = Cms.Core.Constants.Web.Mvc.InstallArea }) ?? "/";
return new LocalRedirectResult(installerUrl);
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// Redirect to login if we're not authorized
return RedirectToLogin(new { returnPath = Url.Action(nameof(AuthorizeUpgrade), this.GetControllerName()) });
}
/// <summary>
/// Returns the JavaScript main file including all references found in manifests
/// </summary>
/// <returns></returns>
[MinifyJavaScriptResult(Order = 0)]
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> Application()
{
var result = await _runtimeMinifier.GetScriptForLoadingBackOfficeAsync(
_globalSettings,
_hostingEnvironment,
_manifestParser);
return new JavaScriptResult(result);
}
/// <summary>
/// Get the json localized text for a given culture or the culture for the current user
/// </summary>
/// <param name="culture"></param>
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
public async Task<Dictionary<string, Dictionary<string, string>>> LocalizedText(string? culture = null)
{
CultureInfo? cultureInfo = null;
if (string.IsNullOrWhiteSpace(culture))
{
// Force authentication to occur since this is not an authorized endpoint, we need this to get a user.
AuthenticateResult authenticationResult = await this.AuthenticateBackOfficeAsync();
// We have to get the culture from the Identity, we can't rely on thread culture
// It's entirely likely for a user to have a different culture in the backoffice, than their system.
IIdentity? user = authenticationResult.Principal?.Identity;
if (authenticationResult.Succeeded && user is not null)
{
cultureInfo = user.GetCulture();
}
cultureInfo ??= CultureInfo.GetCultureInfo(_globalSettings.DefaultUILanguage);
}
else
{
cultureInfo = CultureInfo.GetCultureInfo(culture);
}
IDictionary<string, string> allValues = _textService.GetAllStoredValues(cultureInfo!);
var pathedValues = allValues.Select(kv =>
{
var slashIndex = kv.Key.IndexOf('/');
var areaAlias = kv.Key[..slashIndex];
var valueAlias = kv.Key[(slashIndex + 1)..];
return new { areaAlias, valueAlias, value = kv.Value };
});
var nestedDictionary = pathedValues
.GroupBy(pv => pv.areaAlias)
.ToDictionary(pv => pv.Key, pv =>
pv.ToDictionary(pve => pve.valueAlias, pve => pve.value));
return nestedDictionary;
}
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[AngularJsonOnlyConfiguration]
[HttpGet]
public IEnumerable<IGridEditorConfig> GetGridConfig() => _gridConfig.EditorsConfig.Editors;
/// <summary>
/// Returns the JavaScript object representing the static server variables javascript object
/// </summary>
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[MinifyJavaScriptResult(Order = 1)]
public async Task<JavaScriptResult> ServerVariables()
{
// cache the result if debugging is disabled
var serverVars = await _serverVariables.ParseAsync(await _backOfficeServerVariables.GetServerVariablesAsync());
var result = _hostingEnvironment.IsDebugMode
? serverVars
: _appCaches.RuntimeCache.GetCacheItem(
typeof(BackOfficeController) + "ServerVariables",
() => serverVars,
new TimeSpan(0, 10, 0));
return new JavaScriptResult(result);
}
[HttpPost]
[AllowAnonymous]
public ActionResult ExternalLogin(string provider, string? redirectUrl = null)
{
// Only relative urls are accepted as redirect url
// We can't simply use Uri.TryCreate with kind Absolute, as in Linux any relative url would be seen as an absolute file uri
if (redirectUrl == null || !Uri.TryCreate(redirectUrl, UriKind.RelativeOrAbsolute, out Uri? redirectUri) || redirectUri.IsAbsoluteUri)
{
redirectUrl = Url.Action(nameof(Default), this.GetControllerName());
}
// Configures the redirect URL and user identifier for the specified external login
AuthenticationProperties properties =
_signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(properties, provider);
}
/// <summary>
/// Called when a user links an external login provider in the back office
/// </summary>
/// <param name="provider"></param>
/// <returns></returns>
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[HttpPost]
public ActionResult LinkLogin(string provider)
{
// Request a redirect to the external login provider to link a login for the current user
var redirectUrl = Url.Action(nameof(ExternalLinkLoginCallback), this.GetControllerName());
// Configures the redirect URL and user identifier for the specified external login including xsrf data
AuthenticationProperties properties =
_signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User));
return Challenge(properties, provider);
}
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ValidatePasswordResetCode([Bind(Prefix = "u")] int userId, [Bind(Prefix = "r")] string resetCode)
{
BackOfficeIdentityUser? user = await _userManager.FindByIdAsync(userId.ToString(CultureInfo.InvariantCulture));
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
if (user is null)
{
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "reset-password", status = "userNotFound" });
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
var result = await _userManager.VerifyUserTokenAsync(user, "Default", "ResetPassword", resetCode);
return result ?
// Redirect to login with userId and resetCode
RedirectToLogin(new { flow = "reset-password", userId, resetCode }) :
// Redirect to login with error code
RedirectToLogin(new { flow = "reset-password", status = "resetCodeExpired" });
}
/// <summary>
/// Callback path when the user initiates a link login request from the back office to the external provider from the
/// <see cref="LinkLogin(string)" /> action
/// </summary>
/// <remarks>
/// An example of this is here
/// https://github.com/dotnet/aspnetcore/blob/main/src/Identity/samples/IdentitySample.Mvc/Controllers/AccountController.cs#L155
/// which this is based on
/// </remarks>
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)]
[HttpGet]
public async Task<IActionResult> ExternalLinkLoginCallback()
{
BackOfficeIdentityUser? user = await _userManager.GetUserAsync(User);
if (user == null)
{
// ... this should really not happen
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLogin(new { flow = "external-login", status = "localUserNotFound" });
}
ExternalLoginInfo? info =
await _signInManager.GetExternalLoginInfoAsync(await _userManager.GetUserIdAsync(user));
if (info == null)
{
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// Add error and redirect for it to be displayed
return RedirectToLogin(new { flow = "external-login", status = "externalLoginInfoNotFound" });
}
IdentityResult addLoginResult = await _userManager.AddLoginAsync(user, info);
if (addLoginResult.Succeeded)
{
// Update any authentication tokens if succeeded
await _signInManager.UpdateExternalAuthenticationTokensAsync(info);
return RedirectToLocal(Url.Action(nameof(Default), this.GetControllerName()));
}
2020-10-23 14:18:53 +11:00
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// Add errors and redirect for it to be displayed
return RedirectToLogin(new { flow = "external-login", status = "failed" });
}
/// <summary>
/// Used by Default and AuthorizeUpgrade to render as per normal if there's no external login info,
/// otherwise process the external login info.
/// </summary>
/// <returns></returns>
private async Task<IActionResult> RenderDefaultOrProcessExternalLoginAsync(
AuthenticateResult authenticateResult,
Func<IActionResult> defaultResponse)
{
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
ArgumentNullException.ThrowIfNull(defaultResponse);
ViewData.SetUmbracoPath(_globalSettings.GetUmbracoMvcArea(_hostingEnvironment));
Merge remote-tracking branch 'origin/v8/dev' into v9/feature/merge-v8-05072021 # Conflicts: # build/NuSpecs/UmbracoCms.Web.nuspec # src/SolutionInfo.cs # src/Umbraco.Core/Compose/RelateOnTrashComponent.cs # src/Umbraco.Core/Composing/Current.cs # src/Umbraco.Core/Constants-AppSettings.cs # src/Umbraco.Core/Constants-SqlTemplates.cs # src/Umbraco.Core/Dashboards/ContentDashboardSettings.cs # src/Umbraco.Core/Dashboards/IContentDashboardSettings.cs # src/Umbraco.Core/Extensions/PublishedPropertyExtension.cs # src/Umbraco.Core/HealthChecks/Checks/Services/SmtpCheck.cs # src/Umbraco.Core/Models/IReadOnlyContentBase.cs # src/Umbraco.Core/Models/Mapping/MemberTabsAndPropertiesMapper.cs # src/Umbraco.Core/Models/Mapping/UserMapDefinition.cs # src/Umbraco.Core/Models/ReadOnlyContentBaseAdapter.cs # src/Umbraco.Core/Persistence/NPocoDatabaseExtensions-Bulk.cs # src/Umbraco.Core/PropertyEditors/IPropertyCacheCompression.cs # src/Umbraco.Core/PropertyEditors/IPropertyCacheCompressionOptions.cs # src/Umbraco.Core/PropertyEditors/MediaPicker3Configuration.cs # src/Umbraco.Core/PropertyEditors/NoopPropertyCacheCompressionOptions.cs # src/Umbraco.Core/PropertyEditors/PropertyCacheCompression.cs # src/Umbraco.Core/Routing/UrlProviderExtensions.cs # src/Umbraco.Core/Runtime/CoreRuntime.cs # src/Umbraco.Core/Services/ILocalizedTextService.cs # src/Umbraco.Core/Services/LocalizedTextServiceExtensions.cs # src/Umbraco.Examine.Lucene/BackOfficeExamineSearcher.cs # src/Umbraco.Examine/UmbracoContentIndex.cs # src/Umbraco.Infrastructure/Examine/GenericIndexDiagnostics.cs # src/Umbraco.Infrastructure/IPublishedContentQuery.cs # src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs # src/Umbraco.Infrastructure/Models/MediaWithCrops.cs # src/Umbraco.Infrastructure/Persistence/NPocoDatabaseExtensions.cs # src/Umbraco.Infrastructure/Persistence/UmbracoDatabase.cs # src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs # src/Umbraco.Infrastructure/PropertyEditors/MediaPicker3PropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs # src/Umbraco.Infrastructure/PropertyEditors/UploadFileTypeValidator.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/ImageCropperValue.cs # src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MediaPickerWithCropsValueConverter.cs # src/Umbraco.Infrastructure/PublishedContentQuery.cs # src/Umbraco.Infrastructure/Search/UmbracoTreeSearcherFields.cs # src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs # src/Umbraco.Persistence.SqlCe/SqlCeSyntaxProvider.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.DictionaryOfPropertyDataSerializer.cs # src/Umbraco.PublishedCache.NuCache/DataSource/BTree.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentData.cs # src/Umbraco.PublishedCache.NuCache/DataSource/ContentSourceDto.cs # src/Umbraco.PublishedCache.NuCache/DataSource/PropertyData.cs # src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentTypeServiceVariantsTests.cs # src/Umbraco.Tests.UnitTests/Umbraco.Web.Common/ImageCropperTest.cs # src/Umbraco.Tests/App.config # src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs # src/Umbraco.Tests/PublishedContent/NuCacheTests.cs # src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs # src/Umbraco.Web.BackOffice/Controllers/CodeFileController.cs # src/Umbraco.Web.BackOffice/Controllers/ContentController.cs # src/Umbraco.Web.BackOffice/Controllers/ContentTypeControllerBase.cs # src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs # src/Umbraco.Web.BackOffice/Controllers/DataTypeController.cs # src/Umbraco.Web.BackOffice/Controllers/MediaController.cs # src/Umbraco.Web.BackOffice/Controllers/PackageInstallController.cs # src/Umbraco.Web.BackOffice/Controllers/TemplateQueryController.cs # src/Umbraco.Web.BackOffice/Mapping/ContentMapDefinition.cs # src/Umbraco.Web.BackOffice/Trees/ContentTreeControllerBase.cs # src/Umbraco.Web.BackOffice/Trees/DataTypeTreeController.cs # src/Umbraco.Web.BackOffice/Trees/MediaTypeTreeController.cs # src/Umbraco.Web.Common/Extensions/FriendlyImageCropperTemplateExtensions.cs # src/Umbraco.Web.Common/Extensions/ImageCropperTemplateCoreExtensions.cs # src/Umbraco.Web.Common/Macros/MacroRenderer.cs # src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml # src/Umbraco.Web.UI/Umbraco/config/lang/it.xml # src/Umbraco.Web.UI/web.Template.Debug.config # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Compose/NotificationsComponent.cs # src/Umbraco.Web/Composing/ModuleInjector.cs # src/Umbraco.Web/Editors/AuthenticationController.cs # src/Umbraco.Web/Editors/BackOfficeController.cs # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/Editors/CurrentUserController.cs # src/Umbraco.Web/Editors/DictionaryController.cs # src/Umbraco.Web/Editors/MediaTypeController.cs # src/Umbraco.Web/Editors/MemberController.cs # src/Umbraco.Web/Editors/MemberGroupController.cs # src/Umbraco.Web/Editors/MemberTypeController.cs # src/Umbraco.Web/Editors/NuCacheStatusController.cs # src/Umbraco.Web/Editors/UserGroupsController.cs # src/Umbraco.Web/Editors/UsersController.cs # src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/ConfigurationService.cs # src/Umbraco.Web/HealthCheck/Checks/Config/CustomErrorsCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/MacroErrorsCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/NotificationEmailCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/TraceCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Config/TrySkipIisCustomErrorsCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Security/ExcessiveHeadersCheck.cs # src/Umbraco.Web/HealthCheck/Checks/Security/HttpsCheck.cs # src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs # src/Umbraco.Web/Models/Trees/MenuItemList.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/ContentCacheDataModel.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/DatabaseDataSource.cs # src/Umbraco.Web/PublishedCache/NuCache/DataSource/SerializerBase.cs # src/Umbraco.Web/PublishedCache/NuCache/NuCacheComposer.cs # src/Umbraco.Web/Runtime/WebRuntime.cs # src/Umbraco.Web/Search/ExamineComponent.cs # src/Umbraco.Web/Trees/ApplicationTreeController.cs # src/Umbraco.Web/Trees/MemberTreeController.cs # src/Umbraco.Web/UrlHelperRenderExtensions.cs
2021-07-05 20:58:04 +02:00
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// check if there is the TempData or cookies with the any token name specified, if so, assign to view bag and render the view
if (ViewData.FromBase64CookieData<BackOfficeExternalLoginProviderErrors>(
_httpContextAccessor.HttpContext,
ViewDataExtensions.TokenExternalSignInError,
_jsonSerializer) ||
ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) || ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode))
{
return defaultResponse();
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
// First check if there's external login info, if there's not proceed as normal
ExternalLoginInfo? loginInfo = await _signInManager.GetExternalLoginInfoAsync();
if (loginInfo != null)
{
// we're just logging in with an external source, not linking accounts
return await ExternalSignInAsync(loginInfo, defaultResponse);
}
2020-12-02 12:22:08 +11:00
// If we are authenticated then we can just render the default view
if (authenticateResult.Succeeded)
{
return defaultResponse();
}
2020-12-02 12:22:08 +11:00
// If the user is not logged in, check if there's any auto login redirects specified
var oauthRedirectAuthProvider = _externalLogins.GetAutoLoginProvider();
// If there's no auto login provider specified, then we'll render the default view
if (oauthRedirectAuthProvider.IsNullOrWhiteSpace())
{
return defaultResponse();
}
// If the ?logout=true query string is not specified, then we'll redirect to the external login provider
// which will then redirect back to the ExternalLoginCallback action
if (Request.Query.TryGetValue("logout", out StringValues logout) == false || logout != "true")
{
return ExternalLogin(oauthRedirectAuthProvider);
}
return defaultResponse();
}
2020-12-02 12:22:08 +11:00
private async Task<IActionResult> ExternalSignInAsync(ExternalLoginInfo loginInfo, Func<IActionResult> response)
{
if (loginInfo == null)
{
throw new ArgumentNullException(nameof(loginInfo));
}
2020-12-02 12:22:08 +11:00
if (response == null)
{
throw new ArgumentNullException(nameof(response));
}
2020-12-02 12:22:08 +11:00
// Sign in the user with this external login provider (which auto links, etc...)
SignInResult result = await _signInManager.ExternalLoginSignInAsync(loginInfo, false, _securitySettings.Value.UserBypassTwoFactorForExternalLogins);
var errors = new List<string>();
if (result == SignInResult.Success)
{
// Update any authentication tokens if succeeded
await _signInManager.UpdateExternalAuthenticationTokensAsync(loginInfo);
// Check if we are in an upgrade state, if so we need to redirect
if (_runtimeState.Level == RuntimeLevel.Upgrade)
2020-10-23 14:18:53 +11:00
{
// redirect to the the installer
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
return RedirectToLocal(null);
2020-10-23 14:18:53 +11:00
}
}
else if (result == SignInResult.TwoFactorRequired)
{
BackOfficeIdentityUser? attemptedUser = await _userManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey);
if (attemptedUser?.UserName is null)
{
return new ValidationErrorResult(
$"No local user found for the login provider {loginInfo.LoginProvider} - {loginInfo.ProviderKey}");
}
2020-10-23 14:18:53 +11:00
var twofactorView = _backOfficeTwoFactorOptions.GetTwoFactorView(attemptedUser.UserName);
if (twofactorView.IsNullOrWhiteSpace())
2020-10-23 14:18:53 +11:00
{
return new ValidationErrorResult(
$"The registered {typeof(IBackOfficeTwoFactorOptions)} of type {_backOfficeTwoFactorOptions.GetType()} did not return a view for two factor auth ");
2020-10-23 14:18:53 +11:00
}
// create a with information to display a custom two factor send code view
var verifyResponse =
new ObjectResult(new { twoFactorView = twofactorView, userId = attemptedUser.Id })
{
StatusCode = StatusCodes.Status402PaymentRequired
};
return verifyResponse;
}
else if (result == SignInResult.LockedOut)
{
errors.Add(
$"The local user {loginInfo.Principal.Identity?.Name} for the external provider {loginInfo.ProviderDisplayName} is locked out.");
}
else if (result == SignInResult.NotAllowed)
{
// This occurs when SignInManager.CanSignInAsync fails which is when RequireConfirmedEmail , RequireConfirmedPhoneNumber or RequireConfirmedAccount fails
// however since we don't enforce those rules (yet) this shouldn't happen.
errors.Add(
$"The user {loginInfo.Principal.Identity?.Name} for the external provider {loginInfo.ProviderDisplayName} has not confirmed their details and cannot sign in.");
}
else if (result == SignInResult.Failed)
{
// Failed only occurs when the user does not exist
errors.Add("The requested provider (" + loginInfo.LoginProvider +
") has not been linked to an account, the provider must be linked from the back office.");
}
else if (result == ExternalLoginSignInResult.NotAllowed)
{
// This occurs when the external provider has approved the login but custom logic in OnExternalLogin has denined it.
errors.Add(
$"The user {loginInfo.Principal.Identity?.Name} for the external provider {loginInfo.ProviderDisplayName} has not been accepted and cannot sign in.");
}
else if (result == AutoLinkSignInResult.FailedNotLinked)
{
errors.Add("The requested provider (" + loginInfo.LoginProvider +
") has not been linked to an account, the provider must be linked from the back office.");
}
else if (result == AutoLinkSignInResult.FailedNoEmail)
{
errors.Add(
$"The requested provider ({loginInfo.LoginProvider}) has not provided the email claim {ClaimTypes.Email}, the account cannot be linked.");
}
else if (result is AutoLinkSignInResult autoLinkSignInResult && autoLinkSignInResult.Errors.Count > 0)
{
errors.AddRange(autoLinkSignInResult.Errors);
}
else if (!result.Succeeded)
{
// this shouldn't occur, the above should catch the correct error but we'll be safe just in case
errors.Add($"An unknown error with the requested provider ({loginInfo.LoginProvider}) occurred.");
2020-10-23 14:18:53 +11:00
}
if (errors.Count > 0)
{
// the external user might actually be signed in at this point, but certain errors (i.e. missing claims)
// prevents us from applying said user to a back-office session. make sure the sign-in manager does not
// report the user as being signed in for subsequent requests.
await _signInManager.SignOutAsync();
ViewData.SetExternalSignInProviderErrors(
new BackOfficeExternalLoginProviderErrors(
loginInfo.LoginProvider,
errors));
}
return response();
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
private RedirectResult RedirectToLocal(string? returnUrl)
{
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
return Redirect("/");
}
V13: New login screen (#14780) * implement interface * add build targets for login screen * package lock * move components to pages folder * load logo and background from property * styling * move mocks around * remove unused vars * add backoffice handlers * install rxjs * add mock data * add element and context for localization * mock data * use umb-localize * remove the extra logic with check for section_ * change key for login button * add base to vite environment * login styling * cleanup and button styling * use correct reset url * change body of reset request * validate password reset code * redirect to /login/new on reset password code verify * add obsolete messages * remove inline scripts for old backoffice * remove shadowdom from localize element * Revert "remove shadowdom from localize element" This reverts commit 46ae282f7ce9235c15f160d57d54acd5d3378668. * hook up reset password to api * rename pages to state as it is not actually used as different pages * reset password styling * more styling * add confirmation page to new password * set router to firstUpdated to avoid rAF * set a custom baseUrl on the router to make sure it works without trailing slash * use route parameters to redirect on the login page to ensure correct escaping * add server variables * make sure auth layout uses the provided properties for images * format * redirect to code expired page * add missing properties * use allowPasswordReset and allowInvite properties in routing and layout * make ts happy * cleanup * init invite page * hook up usernameIsEmail * init external login providers * add mock provider * add padding to buttons * replace uui button with normal button * add external login providers as slot * add disableLocalLogin property * add form to external login providers * remove unused method * fix build errors * add attributes for external login * add custom view to external login * add new custom icon registry * attach two icon registries * use relative paths * use relative paths * use main registry instead of providing directly * add look and color to external login * implement getIcons() method * use getIcons() to request icons * install remixicon to supplement backoffice icons (replacing font-awesome eventually) * move icon registries to auth element * Revert "install remixicon to supplement backoffice icons (replacing font-awesome eventually)" This reverts commit 0c6659d8d9dfe0664314ec6a3acaa8e20cb606ed. * add icons for common external providers * add more icons * remove resetCode hack as it is no longer needed * add validation to new password * get gretting from translation file * add hack to get text left aligned in uui-button * add custom router * WIP Use router * also change the URL during an action * update login action to redirect to /new when needed * redirect to login from reset and new if not allowed * fix new password button href * use property on login element instead of context * check for redirect on invite-user * move fake external login providers to index.html for use in dev server * allow password reset on dev server * add look and color * only set styles for default view buttons * suppress vite import warning * check and inform for errors and show 'nothing' if a custom view fails to load * fix mock path for localizedtext * fix build errors * ensure that msw (and all its dependencies) do not end up in the production bundle (saved ~500 KB) * Revert AngularValueExternalLoginInfoScriptAsync removal * forward the providerName to custom views * change default icon * add button look and color to external login provider options * add obsolete to ButtonStyle and add a mapper to new values * add required xml comments * map external login providers to <umb-login-external /> * fix typo * only show external login layout if there are slotted children * pass on name as "provider" * send externalLoginUrl to custom views * cleanup * global import * hide external logins completely when empty * cleanup * setup redirect to invite * rename pages to name-page * fix names and paths * use new password layout for invite and new password * add comments * cleanup and use confirmation element * set parameters after successful verifyinvite * map display-name and provider-name to the external element * map display-name * set up external login to handle correct display- and provider-name with documentation * add support for disabling local login * update path to handlers * add more localization * add handlers for 2fa * router should support a factory for component * push login to ?flow=mfa on 402 codes * add page to handle 2fa/mfa * add support for custom routing * add fallback for welcome greeting * handle AngularJS silliness * fix typo * fix router and replace custom umbroute:statechange event with native pushState * simplify code and cleanup * a11y improvements * you can now navigate to anywhere from anywhere with pushState * access the "twoFactorView" from the backend * set the default implemented twoFactorView to NULL * add initial logic to handle a custom mfa view * roll back custom pushState changes * add mocks for 2fa custom view * use router redirect * re-enable click url change * cleanup * remove debug buttons * add unsafeHTML to localize element * load mfa custom views * load custom view * improve external login custom views * using optimisation * add current culture * only show mfa page if 402 code has been encountered in same session * format * remove unnesesary action * add new user invite password * remove console log * fix getting stuck at new password page if you've triggered custom validity * unify layouts * add styling to buttons in error layout * remove unused css * add error message to new password page * add error message to reset password * add error message to invite page * fix invite page not being rendered * cleanup * add obsolete notice to PostSetInvitedUserPassword * add request model to set a new password for an invited user * add new method to handle invited user password * add get password config api call * fix password config parameters and add invite call * get invited user * get password config * assign unique guid to login project * add userId to get password config and use the config as validation * fix * add alerts * fix the new password layout * auth redirects invite error to error page * use password config on new password page * remove console log * move file and remove unused extension * make ts happy * file structure * rename login-extern to external-login-provider * update element name * update dependencies * export custom-view.element.ts * remove debug * use umb-custom-view to load custom views * build types * move @umbraco/uui to the login app and import from there in backoffice * make the ui library and icon registry generally available as exports from the login app * add mock handler for icons * cleanup package * use uui for external login providers in the backoffice * add imports and enable the backoffice icon registry globally * disable shadowdom * default background image * use undefined * revert angular values * remove legacy sys variables * add logic to handle mfa in an overlay scenario without routing * add new login screen to replace the overlay when logged in to the backoffice * update spec to work with locators * cleanup of legacy context * ViewData is not always required * add method to solely return the default view of the backoffice to simply BackofficeController as well as unit tests * add test for the login view * cleanup usings * Apply suggestions from code review Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> * remove 'remember me' * add more contrast to external login divider * update dependencies * set "lang" attribute to lowercase * remove default headline * localize the "Or" divider and add aria-hidden * remove Umbraco reference from logo and add aria-hidden * add aria-hidden to uui-icon inside external login buttons * format code * update dependencies * update dependencies * add translations to invite user page * use back to login button * update localization-context.ts to match api from old LocalizeService in Angular * add tsc to watch * formatting * add missing localizations * fix a11y issues with muted text * refresh current user after login * remove unused variable * add localization * add localization for error messages * remove unused var * return user after login and set successful auth * retry request queue after login * add language keys for failed login * add language keys for failed login * render the views without a router so that it works inside a modal in the backoffice * add autocomplete to reset password fields * add autocomplete to login screen * add generic error layout to new-password-page * new-password-layout should be able to handle with and without username * update language keys * check for userId before trying to request invited user * show error when no invited user is found * place back-to-login button on all error layouts * update lockfile --------- Co-authored-by: Jesper Møller Jensen <26099018+JesmoDev@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
2023-10-23 10:06:17 +02:00
/// <summary>
/// Redirect the user to the login action with the specified path as string and parameter as object
/// </summary>
/// <param name="values">Object containing route values</param>
/// <returns>Redirects the user session to the login page</returns>
private LocalRedirectResult RedirectToLogin(object? values)
{
var url = Url.Action(nameof(Login).ToLower(), this.GetControllerName(), values);
return new LocalRedirectResult(url ?? "/");
}
}