mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Added email challenge
--HG-- branch : dev
This commit is contained in:
@@ -116,10 +116,16 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
if (ValidateRegistration(userName, email, password, confirmPassword)) {
|
||||
// Attempt to register the user
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(userName, password, email, null, null, true));
|
||||
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(userName, password, email, null, null, false));
|
||||
|
||||
if (user != null) {
|
||||
if ( user.As<UserPart>().EmailStatus == UserStatus.Pending ) {
|
||||
string challengeToken = _membershipService.GetEncryptedChallengeToken(user.As<UserPart>());
|
||||
_membershipService.SendChallengeEmail(user.As<UserPart>(), Url.AbsoluteAction(() => Url.Action("ChallengeEmail", "Account", new { Area = "Orchard.Users", token = challengeToken })));
|
||||
|
||||
return RedirectToAction("ChallengeEmailSent");
|
||||
}
|
||||
|
||||
_authenticationService.SignIn(user, false /* createPersistentCookie */);
|
||||
return Redirect("~/");
|
||||
}
|
||||
@@ -173,6 +179,21 @@ namespace Orchard.Users.Controllers {
|
||||
return View(new BaseViewModel());
|
||||
}
|
||||
|
||||
public ActionResult ChallengeEmailSent() {
|
||||
return View(new BaseViewModel());
|
||||
}
|
||||
|
||||
public ActionResult ChallengeEmail(string token) {
|
||||
var user = _membershipService.ValidateChallengeToken(token);
|
||||
|
||||
if ( user != null ) {
|
||||
_authenticationService.SignIn(user, false /* createPersistentCookie */);
|
||||
return View("ChallengeEmailSuccess");
|
||||
}
|
||||
|
||||
return View("ChallengeEmailFail");
|
||||
}
|
||||
|
||||
protected override void OnActionExecuting(ActionExecutingContext filterContext) {
|
||||
if (filterContext.HttpContext.User.Identity is WindowsIdentity) {
|
||||
throw new InvalidOperationException("Windows authentication is not supported.");
|
||||
|
@@ -10,6 +10,7 @@ using Orchard.Users.Drivers;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
using Orchard.Mvc.Extensions;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
[ValidateInput(false)]
|
||||
|
Reference in New Issue
Block a user