Exemple #1
0
        /// <summary>
        /// This should run ONLY on the server.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="dal"></param>
        private void LoadUserData(string username, IUserDal dal)
        {
            var result = dal.Fetch(username);

            if (!result.IsSuccess)
            {
                var ex = result.GetExceptionFromInfo();
                if (ex != null)
                {
                    throw ex;
                }
                else
                {
                    throw new DataAccess.Exceptions.LoadUserDataException(result.Msg, username);
                }
            }

            var userDto = result.Obj;


            IsAuthenticated = (userDto != null);
            if (IsAuthenticated)
            {
                //PROPERTIES
                Name   = userDto.Username;
                Salt   = userDto.Salt;
                UserId = userDto.Id;

                //ROLES
                var resultRoles = dal.GetRoles(Name);
                if (!result.IsSuccess)
                {
                    Exception error = result.GetExceptionFromInfo();
                    if (error != null)
                    {
                        throw error;
                    }
                    else
                    {
                        throw new GeneralDataAccessException(resultRoles.Msg);
                    }
                }

                if (resultRoles.Obj.Count == 0)
                {
                    throw new VeryBadException("Roles.Count == 0.  Every user should have at least one role.");
                }
                Roles = new Csla.Core.MobileList <string>();
                foreach (var roleDto in resultRoles.Obj)
                {
                    Roles.Add(roleDto.Text);
                }
            }
        }
Exemple #2
0
 private void Fetch(UsernameCriteria criteria, [Inject] IUserDal dal)
 {
     ProjectTracker.Dal.UserDto data = null;
     try
     {
         data = dal.Fetch(criteria.Username, criteria.Password);
     }
     catch (ProjectTracker.Dal.DataNotFoundException)
     {
         data = null;
     }
     LoadUser(data);
 }
Exemple #3
0
 private void Fetch(string username, [Inject] IUserDal dal)
 {
     ProjectTracker.Dal.UserDto data = null;
     try
     {
         data = dal.Fetch(username);
     }
     catch (ProjectTracker.Dal.DataNotFoundException)
     {
         data = null;
     }
     LoadUser(data);
 }