Beispiel #1
0
        public async Task <IActionResult> Index([FromQuery(Name = "ReturnUrl")] string returnUrl, string username, string password, ulong guild)
        {
            var identity = await WebAuth.Authorize(username, password, guild);

            if (identity == null)
            {
                return(View(new AuthViewModel(DiscordClient.Guilds.ToList(), true)));
            }

            await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
                                          new ClaimsPrincipal(identity), new AuthenticationProperties()
            {
                ExpiresUtc  = DateTimeOffset.UtcNow.AddHours(1),
                IssuedUtc   = DateTimeOffset.UtcNow,
                RedirectUri = string.IsNullOrEmpty(returnUrl) ? "/" : returnUrl
            });

            return(RedirectToAction("Index", "Admin"));
        }