#18625: Fixing "Remember Me" checkbox

Work Item: 18625

--HG--
branch : 1.x
This commit is contained in:
SeanFarrow
2012-07-03 09:27:11 -07:00
parent 16216121c2
commit ed2c2c948b
3 changed files with 23 additions and 17 deletions

View File

@@ -82,14 +82,14 @@ namespace Orchard.Users.Controllers {
[AlwaysAccessible]
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings",
Justification = "Needs to take same parameter type as Controller.Redirect()")]
public ActionResult LogOn(string userNameOrEmail, string password, string returnUrl) {
public ActionResult LogOn(string userNameOrEmail, string password, string returnUrl, bool rememberMe) {
var user = ValidateLogOn(userNameOrEmail, password);
if (!ModelState.IsValid) {
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);
return new ShapeResult(this, shape);
}
_authenticationService.SignIn(user, false);
_authenticationService.SignIn(user, rememberMe);
foreach (var userEventHandler in _userEventHandlers) {
userEventHandler.LoggedIn(user);
}

View File

@@ -17,17 +17,20 @@
<fieldset class="login-form group">
<legend>@T("Account Information")</legend>
<ol>
<li>
<label for="username-email">@T("Username")</label>
@Html.TextBox("userNameOrEmail", "", new { id = "username-email", autofocus = "autofocus" })
@Html.ValidationMessage("userNameOrEmail")
</li>
<li>
<label for="password">@T("Password")</label>
@Html.Password("password")
@Html.ValidationMessage("password")
</li>
<button class="primaryAction" type="submit">@T("Sign In")</button>
<li>
<label for="username-email">@T("Username")</label>
@Html.TextBox("userNameOrEmail", "", new { id = "username-email", autofocus = "autofocus" })
@Html.ValidationMessage("userNameOrEmail")
</li>
<li>
<label for="password">@T("Password")</label>
@Html.Password("password")
@Html.ValidationMessage("password")
</li>
<li>
@Html.CheckBox("rememberMe", new { id = "remember-me" })<label class="forcheckbox" for="remember-me">@T("Remember Me")</label>
</li>
</ol>
<button class="primaryAction" type="submit">@T("Sign In")</button>
</fieldset>
}

View File

@@ -20,8 +20,7 @@ namespace Orchard.Security.Providers {
Logger = NullLogger.Instance;
// TEMP: who can say...
ExpirationTimeSpan = TimeSpan.FromHours(6);
ExpirationTimeSpan = TimeSpan.FromDays(30);
}
public ILogger Logger { get; set; }
@@ -51,6 +50,10 @@ namespace Orchard.Security.Providers {
cookie.Domain = FormsAuthentication.CookieDomain;
}
if (createPersistentCookie) {
cookie.Expires = ticket.Expiration;
}
var httpContext = _httpContextAccessor.Current();
httpContext.Response.Cookies.Add(cookie);
_signedInUser = user;