Class UmbExternalLoginController
Surface controller that handles external (OAuth/OpenID) sign-in, sign-in callbacks, account linking and disassociation for members.
Namespace: Umbraco.Cms.Web.Website.Controllers
Assembly: Umbraco.Web.Website.dll
Syntax
[UmbracoMemberAuthorize]
public class UmbExternalLoginController : SurfaceController, IDiscoverable
Constructors
View SourceUmbExternalLoginController(ILogger<UmbExternalLoginController>, IUmbracoContextAccessor, IUmbracoDatabaseFactory, ServiceContext, AppCaches, IProfilingLogger, IPublishedUrlProvider, IMemberSignInManager, IMemberManager, ITwoFactorLoginService, IOptions<SecuritySettings>)
Initializes a new instance of the UmbExternalLoginController class.
Declaration
public UmbExternalLoginController(ILogger<UmbExternalLoginController> logger, IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IPublishedUrlProvider publishedUrlProvider, IMemberSignInManager memberSignInManager, IMemberManager memberManager, ITwoFactorLoginService twoFactorLoginService, IOptions<SecuritySettings> securitySettings)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<UmbExternalLoginController> | logger | |
| IUmbracoContextAccessor | umbracoContextAccessor | |
| IUmbracoDatabaseFactory | databaseFactory | |
| ServiceContext | services | |
| AppCaches | appCaches | |
| IProfilingLogger | profilingLogger | |
| IPublishedUrlProvider | publishedUrlProvider | |
| IMemberSignInManager | memberSignInManager | |
| IMemberManager | memberManager | |
| ITwoFactorLoginService | twoFactorLoginService | |
| IOptions<SecuritySettings> | securitySettings |
Methods
View SourceDisassociate(string, string, string?)
Removes the link between the authenticated member and an external login provider.
Declaration
[HttpPost]
[ValidateAntiForgeryToken]
public Task<IActionResult> Disassociate(string provider, string providerKey, string? returnUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | provider | The name of the external login provider to unlink. |
| string | providerKey | The provider-assigned key identifying the external login. |
| string | returnUrl | Optional URL to redirect to on success. |
Returns
| Type | Description |
|---|---|
| Task<IActionResult> | A redirect to the return URL on success; otherwise the current page with identity errors added to ModelState. |
ExternalLinkLoginCallback(string)
Endpoint used by the login provider to call back after an account-linking attempt.
Declaration
[HttpGet]
public Task<IActionResult> ExternalLinkLoginCallback(string returnUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| string | returnUrl | The URL to redirect to after a successful link. |
Returns
| Type | Description |
|---|---|
| Task<IActionResult> | A redirect to the return URL on success; otherwise the current page with provider errors populated in Microsoft.AspNetCore.Mvc.Controller.ViewData. |
ExternalLogin(string, string?)
Endpoint used to redirect to a specific login provider. This endpoint is used from the Login snippet.
Declaration
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string? returnUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | provider | |
| string | returnUrl |
Returns
| Type | Description |
|---|---|
| ActionResult |
ExternalLoginCallback(string)
Endpoint used by the login provider to call back to our solution after an external sign-in attempt.
Declaration
[HttpGet]
[AllowAnonymous]
public Task<IActionResult> ExternalLoginCallback(string returnUrl)
Parameters
| Type | Name | Description |
|---|---|---|
| string | returnUrl | The URL to redirect to after a successful sign-in. |
Returns
| Type | Description |
|---|---|
| Task<IActionResult> | A redirect to the return URL on success; a 400 response when no local member can be matched for a two-factor challenge; otherwise the current page with provider errors populated in Microsoft.AspNetCore.Mvc.Controller.ViewData. |
LinkLogin(string, string?)
Begins the flow that links an external login provider to the currently authenticated member's account.
Declaration
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult LinkLogin(string provider, string? returnUrl = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | provider | The name of the external login provider. |
| string | returnUrl | Optional URL to redirect to after the link callback completes. |
Returns
| Type | Description |
|---|---|
| IActionResult | A challenge result that redirects to the external provider. |