Example #1
0
        public async Task <IActionResult> ExternalLoginCallback(string returnUrl = null)
        {
            var ip         = HttpContext.Connection.RemoteIpAddress.ToString();
            var loginState = _externalLoginTempService.Read();

            if (loginState == null)
            {
                await _securityLogService.CreateLogEntry((User)null, null, ip, "Temp auth cookie missing on callback", SecurityLogType.ExternalAssociationCheckFailed);

                return(View("ExternalError", Resources.LoginBad));
            }
            var externalLoginInfo = new ExternalLoginInfo(loginState.ProviderType.ToString(), loginState.ResultData.ID, loginState.ResultData.Name);
            var matchResult       = await _externalUserAssociationManager.ExternalUserAssociationCheck(externalLoginInfo, ip);

            if (matchResult.Successful)
            {
                await _userService.Login(matchResult.User, ip);

                _externalLoginTempService.Remove();
                await PerformSignInAsync(matchResult.User, HttpContext);

                return(Redirect(returnUrl));
            }
            ViewBag.Referrer = returnUrl;
            return(View());
        }
Example #2
0
        public ViewResult Create()
        {
            SetupCreateData();
            var signupData = new SignupData
            {
                IsDaylightSaving = true,
                IsSubscribed     = true,
                TimeZone         = _settingsManager.Current.ServerTimeZone
            };
            var loginState = _externalLoginTempService.Read();

            if (loginState?.ResultData != null)
            {
                signupData.Email = loginState.ResultData.Email;
                signupData.Name  = loginState.ResultData.Name;
            }
            return(View(signupData));
        }