1
0
mirror of https://github.com/bitwarden/server synced 2026-01-04 17:43:53 +00:00

passwordless signin for billing portal

This commit is contained in:
Kyle Spearrin
2018-03-20 15:00:56 -04:00
parent 9ed1ae9567
commit 3d9d193bda
16 changed files with 486 additions and 7 deletions

View File

@@ -0,0 +1,48 @@
using System.Threading.Tasks;
using Bit.Billing.Models;
using Bit.Core.Identity;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
namespace Billing.Controllers
{
public class LoginController : Controller
{
private readonly PasswordlessSignInManager<IdentityUser> _signInManager;
public LoginController(
PasswordlessSignInManager<IdentityUser> signInManager)
{
_signInManager = signInManager;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(LoginModel model)
{
var result = await _signInManager.PasswordlessSignInAsync(model.Email);
if(!result.Succeeded)
{
return View("Error");
}
return RedirectToAction("Index", "Home");
}
public async Task<IActionResult> Confirm(string email, string token)
{
var result = await _signInManager.PasswordlessSignInAsync(email, token, false);
if(!result.Succeeded)
{
return View("Error");
}
return RedirectToAction("Index", "Home");
}
}
}