示例#1
0
 public bool VerifyChange(int uid, string password, string passwordNew)
 {
     return(Change(uid, passwordNew, passwordDb => {
         password = YoConvert.ToMD5(password);
         return password == passwordDb;
     }));
 }
示例#2
0
 public bool Add(sys_user row)
 {
     if (!check(row))
     {
         return(false);
     }
     row.password = YoConvert.ToMD5(row.password);
     return(AddRow(row));
 }
示例#3
0
 public bool ChangePassword(sys_user row, string passwordNew)
 {
     row.password = passwordNew;
     if (!check(row))
     {
         return(false);
     }
     row.password = YoConvert.ToMD5(row.password);
     return(ModifyRow(row));
 }
示例#4
0
        public bool Login(string uname, string password)
        {
            bool result = false;

            while (true)
            {
                // get user
                object obj = uname;
                if (YoConvert.ToInt(ref obj))
                {
                    m_userModel.FindMobile(uname);
                }
                else
                {
                    m_userModel.FindUname(uname);
                }

                var user = m_userModel.Row;
                if (user == null)
                {
                    m_errorDict[SYS] = "no user";
                    break;
                }

                password = YoConvert.ToMD5(password);
                if (user.password != password)
                {
                    m_errorDict[SYS] = "wrong password";
                    break;
                }

                // get token
                if (m_tokenModel.FindUid(user.id))
                {
                    result = m_tokenModel.Update(m_tokenModel.Row);
                    break;
                }

                var token = new sys_token();
                token.ticket = YoConvert.ToMD5(user.id + "_" + DateTime.Now);
                token.uid    = user.id;
                result       = m_tokenModel.Add(token);

                break;
            }
            return(result);
        }