using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Dough.Models; using Dough.Models.Database; using Dough.Utilities; using IdentityServer4.Services; namespace Dough.Controllers { [AllowAnonymous] public class AccountController : BaseController { private readonly MainDbContext _context; private readonly IIdentityServerInteractionService _identityServerInteractionService; public AccountController(MainDbContext context, IIdentityServerInteractionService identityServerInteractionService) { _context = context; _identityServerInteractionService = identityServerInteractionService; } // This is the default route for identityserver4 logins (https://identityserver4.readthedocs.io/en/latest/topics/signin.html#login-workflow) [HttpPost("login")] public async Task Login(string returnUrl) { if (returnUrl.IsMissing() || !_identityServerInteractionService.IsValidReturnUrl(returnUrl)) return BadRequest("route parameter returnUrl is invalid"); Console.WriteLine("returnUrl: " + returnUrl); var reqBody = await HttpContext.Request.ReadFormAsync(); foreach (var formEl in reqBody) { Console.WriteLine(formEl.Key); foreach (var value in formEl.Value) Console.WriteLine(" - " + value); } return Ok(); } [HttpGet("forgot")] public async Task ForgotPassword(string username) { var user = _context.Users.SingleByNameOrDefault(username); if (user == default) return Ok(); return Ok(); } [Authorize] [HttpGet("me")] public ActionResult GetClaimsForUser() { return Ok(LoggedInUser); } } }