Beispiel #1
0
        /// <summary>
        /// Registers and signs in users
        /// </summary>
        public async Task RegisterUser(string accessToken, string userID, HttpContext httpContext)
        {
            var user = await _userRepository.GetUserByID(userID);

            if (user == null)
            {
                var facebookPictureTask = _facebookClient.GetPictureByteArrayByUserId(userID);
                var facebookUser        = await _facebookClient.GetUserDataFromAccessToken(accessToken);

                await _userRepository.CreateOrUpdateUser(userID, facebookUser.Email, facebookUser.Name, await facebookPictureTask);

                await _authorizationLogic.AuthorizeUser(userID, facebookUser.Name, facebookUser.Email, httpContext);
            }
            else
            {
                // create auth cookie, add claims, authorize user
                await _authorizationLogic.AuthorizeUser(userID, user.FullName, user.Email, httpContext);
            }
        }