blob: fe7b7a2c1f724bd5e0df6f1e58055a2311e8665e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
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<ActionResult> 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<ActionResult> 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);
}
}
}
|