Пример #1
0
        private void DataPortal_Fetch(UsernameCriteria criteria)
        {
            using (var cn = new SqlConnection(BaseDatos.ConexionBD))
            {
                cn.Open();
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = "usp_LoginUser";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Usuario", criteria.Username);
                    cmd.Parameters.AddWithValue("@Clave", criteria.Password);
                    //Recuperamos el Acronimo
                    var acronimo = Csla.ApplicationContext.GlobalContext["Acronimo"] as string;
                    cmd.Parameters.AddWithValue("@Acronimo", acronimo ?? string.Empty);

                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            Fetch(dr);
                        }
                        else
                        {
                            SetNonUserData();
                        }
                    }
                }
            }
        }
Пример #2
0
        private void DataPortal_Fetch(UsernameCriteria criteria)
        {
            AuthenticationType = DalResources.AuthenticationTypeString;
            using (var dalManager = DataAccess.DalFactory.GetDalManager())
            {
                var dal = dalManager.GetProvider <IUserDal>();

                var verifyResult = dal.VerifyUser(criteria.Username, criteria.Password);
                if (!verifyResult.IsSuccess)
                {
                    Exception error = verifyResult.GetExceptionFromInfo();
                    if (error != null)
                    {
                        throw error;
                    }
                    else
                    {
                        throw new FetchFailedException(verifyResult.Msg);
                    }
                }
                bool?userIsVerified = verifyResult.Obj;
                if (userIsVerified == null)
                {
                    userIsVerified = false;
                }

                if (userIsVerified == true)
                {
                    LoadUserData(criteria.Username, dal);
                }

                //return this;
            }
        }
        protected void DataPortal_Fetch(UsernameCriteria criteria)
        {
            using (var ctx = new VacationManagerContext())
            {
                var employee = ctx.Employees
                               .SingleOrDefault(x => x.Email == criteria.Username);

                LoadIdentityFrom(employee);
            }
        }
        protected void DataPortal_Fetch(UsernameCriteria criteria)
        {
            using (var ctx = new VacationManagerContext())
            {
                var employee = ctx.Employees
                    .SingleOrDefault(x => x.Email == criteria.Username);

                LoadIdentityFrom(employee);
            }
        }
Пример #5
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);
 }
Пример #6
0
 private void DataPortal_Fetch(UsernameCriteria criteria)
 {
     ProjectTracker.Dal.UserDto data = null;
     using (var ctx = ProjectTracker.Dal.DalFactory.GetManager())
     {
         var dal = ctx.GetProvider <ProjectTracker.Dal.IUserDal>();
         try
         {
             data = dal.Fetch(criteria.Username, criteria.Password);
         }
         catch (ProjectTracker.Dal.DataNotFoundException)
         {
             data = null;
         }
         LoadUser(data);
     }
 }
Пример #7
0
        private void DataPortal_Fetch(UsernameCriteria criteria)
        {
            UserDto data = null;

            using (var ctx = DalFactoryGetManager.GetManager())
            {
                var dal = ctx.GetProvider <IUserDal>();
                try
                {
                    data = dal.Fetch(criteria.Username);
                    if (data.Id == 0)
                    {
                        status = LoginStatus.Failure;
                        return;
                    }

                    if (data.Is_lock)
                    {
                        status = LoginStatus.LockedOut;
                        return;
                    }

                    if (!data.Is_approved)
                    {
                        status = LoginStatus.IsNotApproved;
                        return;
                    }
                    var salt            = data.Password_salt;
                    var hash            = StringUtils.Encode(criteria.Password, salt);
                    var passwordMatches = hash == data.Password;
                    if (!passwordMatches)
                    {
                        status = LoginStatus.Failure;
                        return;
                    }
                } catch (Exception ex)
                {
                    data   = null;
                    status = LoginStatus.Failure;
                    return;
                }
                LoadUser(data);
                status = LoginStatus.Success;
            }
        }
Пример #8
0
        /// <summary>
        /// Returns the UserIdentity object using the given username and clear, unsalted password.
        /// If there is any problem logging in, then this returns null.
        /// </summary>
        /// <returns>UserIdentity if authenticated, otherwise returns null.</returns>
        public static async Task <UserIdentity> GetUserIdentityAsync(string username, string clearUnsaltedPassword)
        {
            UserIdentity retIdentity = null;
            var          criteria    = new UsernameCriteria(username, clearUnsaltedPassword);

            try
            {
                retIdentity = await DataPortal.FetchAsync <UserIdentity>(criteria);
            }
            catch (Exception ex)
            {
                Services.PublishMessageEvent(ex.Message,
                                             Common.MessagePriority.High,
                                             Common.MessageType.Error);
                retIdentity = null;
            }
            return(retIdentity);
        }
Пример #9
0
        protected void DataPortal_Fetch(UsernameCriteria criteria)
        {
            this.User = RF.Concreate <UserRepository>().GetBy(criteria.Username, criteria.Password);

            this.LoadChildrenProperties();
        }
    private void DataPortal_Fetch(UsernameCriteria credentials)
    {
        this.AuthenticationType = "Custom";
        this.Roles = new Csla.Core.MobileList<string>();
        
        using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.WaldenWebConnection,false))
        {
            using (var cm = ctx.Connection.CreateCommand())
            {
                cm.CommandText = "SELECT count(UserID) FROM Users "
                    + " WHERE UserName = @id and Password = @pwd";
                cm.CommandType = System.Data.CommandType.Text;
                cm.Parameters.AddWithValue("@id", credentials.Username);
                cm.Parameters.AddWithValue("@pwd", credentials.Password);
                using (var dr = new SafeDataReader(cm.ExecuteReader()))
                {
                    dr.Read();

                    if (dr.GetInt32(0) > 0)
                    {
                        this.IsAuthenticated = true;
                    }
                    else
                    {
                        this.Name = "";
                        this.IsAuthenticated = false;
                    }
                }
            }
            if (this.IsAuthenticated)
            {
                using (var ctx2 = ConnectionManager<SqlConnection>.GetManager(Database.WaldenWebConnection, false))
                {
                    using (var cm2 = ctx2.Connection.CreateCommand())
                    {
                        cm2.CommandText = "SELECT A.Role FROM Roles A,Users B "
                            + " WHERE B.UserName = @id and B.Password = @pwd"
                            + " and A.UserID = B.UserID";
                        cm2.CommandType = System.Data.CommandType.Text;
                        cm2.Parameters.AddWithValue("@id", credentials.Username);
                        cm2.Parameters.AddWithValue("@pwd", credentials.Password);
                        using (var dr2 = new SafeDataReader(cm2.ExecuteReader()))
                        {
                            while (dr2.Read())
                            {
                                this.Roles.Add(dr2.GetString(0));
                            }
                        }
                    }
                }
            }
        }
        /*
      this.AuthenticationType = "Custom";
      this.Roles = new Csla.Core.MobileList<string>();
      if (credentials.Username == "test" && credentials.Password == "Pass@word1")
      {
        this.Name = "test";
        this.IsAuthenticated = true;
        this.Roles.Add("Supervisor");
        this.Phone = "555-1234";
      }
      else
      {
        this.Name = "";
        this.IsAuthenticated = false;
      }
         */
    }
Пример #11
0
        protected void DataPortal_Fetch(UsernameCriteria criteria)
        {
            this.User = RF.Concreate<UserRepository>().GetBy(criteria.Username, criteria.Password);

            this.LoadChildrenProperties();
        }
Пример #12
0
        public static UserIdentity GetUserIdentity(string username, string clearUnsaltedPassword)
        {
            var criteria = new UsernameCriteria(username, clearUnsaltedPassword);

            return(DataPortal.Fetch <UserIdentity>(criteria));
        }