Esempio n. 1
0
        public int LogON(string login, string password, out string msg)
        {
            int ret = 0;

            msg = null;

            CUser  clUser = new CUser(null, LocalData.CSDbUsers(), LocalData.LogPath());
            STUser stUser;
            int    retvalue = clUser.GetRecordByUserLogin(login, out stUser, out msg);

            if (retvalue != 0)
            {
                return(-1);
            }
            else
            {
                if (stUser.userid == null)
                {
                    string     smsg  = string.Format("Invalid user ({0})", login);
                    CUdpSender clUDp = new CUdpSender(LocalData.Host(), LocalData.Port(), LocalData.LogPath());
                    clUDp.Send(LocalData.Facility(), LocalData.TagId(), "UWA101", smsg);

                    return(2);
                }

                if (stUser.islock)
                {
                    msg = string.Format("The user \"{0}\" has temporarily blocked for 30 minutes", login);
                    return(3);
                }

                if (!UserModelsRepository.Instance.ValidateLogOnPassword(stUser, password, out msg))
                {
                    string     smsg  = string.Format("Invalid password for user ({0})", login);
                    CUdpSender clUDp = new CUdpSender(LocalData.Host(), LocalData.Port(), LocalData.LogPath());
                    clUDp.Send(LocalData.Facility(), LocalData.TagId(), "UWA102", smsg);
                    // msg = smsg;
                    return(4);
                }

                if (stUser.passvaliddate <= DateTime.Now)
                {
                    return(1);
                }
            }

            return(ret);
        }