示例#1
0
        public async Task <IActionResult> Authorized(string code)
        {
            try
            {
                PartyGoerDetails partyGoerDetails = await _authenticationService.AuthenticateUserWithAccessCodeAsync(code);

                _partyGoerService.SavePartyGoer(partyGoerDetails);

                // Get details from spotify of user
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, partyGoerDetails.Id));

                var principal = new ClaimsPrincipal(identity);

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

                await _logService.LogUserActivityAsync(new PartyGoer(partyGoerDetails.Id), "Successfully authenticated through Spotify");

                return(RedirectToAction("Index", "Dashboard"));
            }
            catch (Exception)
            {
                //  TODO: CHANGE THIS TO THE IDNEX PAGE ON HOME
                return(RedirectToAction("Index", "Dashboard"));
            }
        }