Ejemplo n.º 1
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <returns>User data with validation information.</returns>
        public async Task <User> GPSAuthentication(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }

            var responseBody = await GPSService.GPSService.AuthenticateUser(Constants.GpsWebApiUrl, Constants.GpsWebApiUrl, Constants.ApiKey, Constants.AppId, userName, password);

            var userData = new User
            {
                UserName = userName,
                Password = password,
                IsValid  = JsonConvert.DeserializeObject <bool>(responseBody)
            };

            if (!userData.IsValid)
            {
                return(userData);
            }

            var userExists = UserDataAccesor.GetUserByUserName(userName);

            if (userExists == null || userExists.UserId == 0)
            {
                return(null);
            }

            userExists.IsValid = userData.IsValid;
            return(userExists);
        }
Ejemplo n.º 2
0
 public User GetUserByUserName(string userName)
 {
     return((string.IsNullOrEmpty(userName)) ? new User() : UserDataAccesor.GetUserByUserName(userName));
 }