mirror of
https://github.com/bitwarden/server.git
synced 2025-04-15 18:18:12 -05:00
persist login. allow log out
This commit is contained in:
parent
1b313e6df4
commit
0d12cf9217
@ -40,7 +40,7 @@ namespace Bit.Admin.Controllers
|
|||||||
|
|
||||||
public async Task<IActionResult> Confirm(string email, string token, string returnUrl)
|
public async Task<IActionResult> Confirm(string email, string token, string returnUrl)
|
||||||
{
|
{
|
||||||
var result = await _signInManager.PasswordlessSignInAsync(email, token, false);
|
var result = await _signInManager.PasswordlessSignInAsync(email, token, true);
|
||||||
if(!result.Succeeded)
|
if(!result.Succeeded)
|
||||||
{
|
{
|
||||||
// TODO: error?
|
// TODO: error?
|
||||||
@ -54,5 +54,13 @@ namespace Bit.Admin.Controllers
|
|||||||
|
|
||||||
return RedirectToAction("Index", "Home");
|
return RedirectToAction("Index", "Home");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public async Task<IActionResult> Logout()
|
||||||
|
{
|
||||||
|
await _signInManager.SignOutAsync();
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,9 @@ using Bit.Core.Identity;
|
|||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Stripe;
|
using Stripe;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
@inject SignInManager<IdentityUser> SignInManager
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
@ -39,6 +40,16 @@
|
|||||||
<a class="nav-link" asp-controller="Organizations" asp-action="Index">Organizations</a>
|
<a class="nav-link" asp-controller="Organizations" asp-action="Index">Organizations</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@if(SignInManager.IsSignedIn(User))
|
||||||
|
{
|
||||||
|
<form asp-controller="Login" asp-action="Logout" method="post">
|
||||||
|
<button type="submit" class="btn btn-secondary">Log Out</button>
|
||||||
|
</form>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<a class="btn btn-secondary" asp-controller="Login" asp-action="Index">Log In</a>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@using Microsoft.AspNetCore.Identity
|
||||||
@using Bit.Admin
|
@using Bit.Admin
|
||||||
@using Bit.Admin.Models
|
@using Bit.Admin.Models
|
||||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||||
|
@ -223,7 +223,7 @@ namespace Bit.Core.Utilities
|
|||||||
options.AccessDeniedPath = "/login?accessDenied=1";
|
options.AccessDeniedPath = "/login?accessDenied=1";
|
||||||
options.Cookie.Name = $"Bitwarden_{globalSettings.ProjectName}";
|
options.Cookie.Name = $"Bitwarden_{globalSettings.ProjectName}";
|
||||||
options.Cookie.HttpOnly = true;
|
options.Cookie.HttpOnly = true;
|
||||||
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
|
options.Cookie.Expiration = options.ExpireTimeSpan = TimeSpan.FromDays(2);
|
||||||
options.ReturnUrlParameter = "returnUrl";
|
options.ReturnUrlParameter = "returnUrl";
|
||||||
options.SlidingExpiration = true;
|
options.SlidingExpiration = true;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user