Last active
January 13, 2017 19:45
-
-
Save neilgaietto/a541d02a966177bb1c99 to your computer and use it in GitHub Desktop.
Simple Umbraco 7 Password Reset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[PluginController("PasswordReset")] | |
public class ResetPasswordController : Umbraco.Web.Mvc.SurfaceController | |
{ | |
private MembershipProvider BackOfficeProvider | |
{ | |
get | |
{ | |
if (Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider] == null) | |
{ | |
throw new InvalidOperationException("No membership provider found with name " + | |
UmbracoConfig.For.UmbracoSettings() | |
.Providers.DefaultBackOfficeUserProvider); | |
} | |
return Membership.Providers[UmbracoConfig.For.UmbracoSettings().Providers.DefaultBackOfficeUserProvider]; | |
} | |
} | |
/// <summary> | |
/// Password reset for when your are locked out of umbraco | |
/// </summary> | |
/// <returns>returns new password for "username" </returns> | |
/// /umbraco/PasswordReset/ResetPassword/Reset | |
[HttpGet] | |
public ActionResult Reset() | |
{ | |
var user = BackOfficeProvider.GetUser("username", false); | |
return Content(user.ResetPassword()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment