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

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

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

            return(Redirect(string.IsNullOrEmpty(returnUrl) ? "/" : returnUrl));
        }