rasmus_rasmussen
08/17/2023, 8:29 AMcs
@using (Html.BeginUmbracoForm<UmbLoginController>(
"HandleLogin", new { RedirectUrl = loginModel.RedirectUrl })) {
<h4>Log in with a local account.</h4>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="mb-3">
<label asp-for="@loginModel.Username" class="form-label"></label>
<input asp-for="@loginModel.Username" class="form-control" />
<span asp-validation-for="@loginModel.Username" class="form-text text-danger"></span>
</div>
<div class="mb-3">
<label asp-for="@loginModel.Password" class="form-label"></label>
<input asp-for="@loginModel.Password" class="form-control" />
<span asp-validation-for="@loginModel.Password" class="form-text text-danger"></span>
</div>
<div class="mb-3 form-check">
<input asp-for="@loginModel.RememberMe" class="form-check-input">
<label asp-for="@loginModel.RememberMe" class="form-check-label">
@Html.DisplayNameFor(m => loginModel.RememberMe)
</label>
</div>
<button type="submit" class="btn btn-primary">Log in</button>
}
It's the <input asp-for="@loginModel.RememberMe" class="form-check-input">
I'm looking at.
EDIT: I have seen that you can create a global cookie in appsettings, but I need remember me to be able to be turned on or off.
EDIT: I'm using UmbAlternativeLoginController
What I would like to ask is, how do I change the default timeout for the member that is signing in, with the remember me button?rasmus_rasmussen
08/17/2023, 9:00 AMUmbLoginController
, and add a line before the return at the bottom, where it checks if the remember me button is checked. And if it's checked, it redirects to a view called /remembered. And that page redirects to the index.
In startup.cs, I have a few lines:
cs
services.ConfigureApplicationCookie(options =>
// Both of these triggers
{
options.Cookie.Name = "DontRememberMe";
options.Cookie.HttpOnly = false;
options.ExpireTimeSpan = TimeSpan.FromMinutes(1);
options.LoginPath = "/Views/MacroPartials/Login";
options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
options.SlidingExpiration = false;
//options.Cookie.Expiration = TimeSpan.FromMinutes(1);
options.Cookie.MaxAge = TimeSpan.FromMinutes(1);
});
// This is the longest running cookie, and therefore it's the cookie that decides when the user is logged out
services.ConfigureApplicationCookie(options =>
{
options.Cookie.Name = "RememberMe";
options.Cookie.HttpOnly = false;
options.ExpireTimeSpan = TimeSpan.FromMinutes(10);
options.LoginPath = "/Views/Remembered";
options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
options.SlidingExpiration = false;
//options.Cookie.Expiration = TimeSpan.FromMinutes(1);
options.Cookie.MaxAge = TimeSpan.FromMinutes(10);
});
And in my UmbAlternativeLoginController
cs
if (model.RememberMe)
{
return Redirect("/Remembered");
}
return RedirectToCurrentUmbracoUrl();
rasmus_rasmussen
08/17/2023, 9:00 AM