public async Task <IHttpActionResult> SignInLinkedin(SignInLinkedinModel model)
        {
            this.CheckModelStateIsValid();

            string token;
            var    userSession = this.GetCurrentUserSession();

            if (userSession == null)
            {
                var externalUserDetails = await LinkedinUserDetailsProvider.GetUserDetails(model, Request.GetOwinContext().Request.CallCancelled);

                userSession = _userSessionBusinessLogic.CreateSessionForExternalUser(externalUserDetails);

                token = JwtHelper.Create(userSession);
            }
            else
            {
                Log.InfoFormat("User '{0}' is already signed-in. Reusing existing session.", userSession.UserId);

                // return the bearer token received
                token = Request.Headers.Authorization.Parameter;
            }

            var result = new SignInResultModel
            {
                Token = token
            };

            return(Ok(result));
        }
Пример #2
0
        public async Task <IActionResult> SignInLinkedin([FromBody] SignInLinkedinModel model)
        {
            this.CheckModelStateIsValid();

            string token;
            var    userSession = await this.GetCurrentUserSession();

            if (userSession == null)
            {
                var externalUserDetails = await LinkedinUserDetailsProvider.GetUserDetails(HttpContext.RequestServices, model, Request.HttpContext.RequestAborted);

                userSession = await _userSessionBusinessLogic.CreateSessionForExternalUser(externalUserDetails);

                token = _jwtSecurityTokenFactory.Create(userSession);
            }
            else
            {
                _logger.LogInformation("User '{0}' is already signed-in. Reusing existing session.", userSession.UserId);

                // return the bearer token received
                //TODO: token = Request.Headers. Authorization.Parameter;
                token = "TODO";
            }

            var result = new SignInResultModel
            {
                Token = token
            };

            return(Ok(result));
        }