public override MembershipUser GetUser(string username, bool userIsOnline)
    {
        zdkUserModel loggedUser = new zdkUserModel();
        UserModelDAL umd        = new UserModelDAL();

        UserModel currentUser = umd.GetByUserName(username);

        if (null != currentUser)
        {
            loggedUser.DistrictID   = currentUser.DistrictID;
            loggedUser.DistrictName = currentUser.DistrictName;
            loggedUser.Email        = currentUser.Email;
            loggedUser.FriendlyName = currentUser.FirstName;
            loggedUser.FacilitiesID = currentUser.FacilitiesID;
            loggedUser.Password     = currentUser.Password;
            loggedUser.User         = currentUser;

            if (currentUser.ServerAdmin == true)
            {
                //for ServerAdmin impersonation reasons

                if (null != currentUser.ImpersonatedID)
                {
                    loggedUser.ImpersonatedName = umd.GetById((Guid)currentUser.ImpersonatedID).UserName;
                }
                else
                {
                    loggedUser.ImpersonatedName = currentUser.UserName;
                }
            }
        }
        return(loggedUser);
    }
    public override bool ValidateUser(string username, string password)
    {
        UserModel currentUser = default(UserModel);

        zdkMembershipProvider zdkmp = new zdkMembershipProvider();
        string encPassword          = zdkmp.EncryptPassword(password);

        UserModelDAL umd = new UserModelDAL();

        //to set password for testing
        ////UserModel eraseMe = new UserModel();
        ////eraseMe.Password = encPassword;
        //umd.Update(eraseMe);

        currentUser = umd.GetByUserName(username);// userRep.GetByUserName(username);

        if (currentUser != null)
        {
            if ((currentUser.Password == encPassword) && (true == currentUser.IsActive)) //password)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
        public int newUser()
        {
            UserModel User   = new UserModel(Nom, Mail, Password, Image, Money);
            int       result = UserModelDAL.InsertIfNotExist(User);

            if (result == 0)
            {
                result = 0;
            }
            else
            {
                result = 1;
            }
            List <UserModel> listeControle = new List <UserModel>(UserModelDAL.GetUsers());

            Console.WriteLine("In newUser(), result is: " + result.ToString());
            return(result);
        }
Ejemplo n.º 4
0
 public void connectToUser(string mail, string password)
 {
     RefreshData();
     data.currentUser = UserModelDAL.TryToConnect(mail, password);
 }