Beispiel #1
0
        public AuthenticationResponse LogOn(string token)
        {
            AuthenticationResponse response = null;

            // ONLY TO USE IN DEMOS WITHOUT INTERNET!
            if (Convert.ToBoolean(WebConfigurationManager.AppSettings["OfflineMode"]))
            {
                return(GetFakeAuthorization());
            }

            if (String.IsNullOrEmpty(token))
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            RegisteredUser registeredUser = _facebookService.GetUserInformation(token);

            if (registeredUser != null && !String.IsNullOrEmpty(registeredUser.FacebookId))
            {
                int registeredUserId = _registeredUserRepository.Add(registeredUser);
                if (registeredUserId > 0)
                {
                    response = new AuthenticationResponse();
                    response.RegisteredUserId = registeredUserId;
                    response.UserName         = registeredUser.Name;
                    response.Token            = MyEventsToken.CreateToken(registeredUserId);
                    response.ExpirationTime   = TimeSpan.FromHours(1).TotalMilliseconds;
                    response.FacebookUserId   = registeredUser.FacebookId;
                }
            }

            return(response);
        }
Beispiel #2
0
        /// <summary>
        /// Add RegisteredUser
        /// </summary>
        /// <param name="registeredUser">registeredUser information</param>
        /// <returns>RegisteredUser id</returns>
        public int PostRegisteredUserCreateIfNotExists(RegisteredUser registeredUser)
        {
            if (registeredUser == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            return(_registeredUserRepository.Add(registeredUser));
        }
Beispiel #3
0
        private int AddUser(MyEventsIdentity identity)
        {
            var user = new RegisteredUser()
            {
                Email      = identity.Email,
                FacebookId = identity.ThirdPartyUserId,
                Name       = identity.UserName,
                Bio        = identity.Bio,
                City       = identity.City
            };

            int registeredUserId = _registeredUserRepository.Add(user);

            return(registeredUserId);
        }