Пример #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"));
            }
        }
Пример #2
0
        public async Task <IActionResult> Authorized(string code)
        {
            try
            {
                PartyGoer newUser = await _authenticationService.AuthenticateUserWithAccessCodeAsync(code);

                if (!newUser.HasPremium())
                {
                    // TODO: create this
                    return(RedirectToAction("NoPremium", "Error"));
                }

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

                var principal = new ClaimsPrincipal(identity);

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

                await _logService.LogUserActivityAsync(newUser, "Successfully authenticated through Spotify");

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