Beispiel #1
0
        /// <summary>
        /// 获取用户登录信息
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <UserInfo> GetLoginInfo()
        {
            var loginInfo = new List <UserInfo>();

            if (InfoFile.Exists)
            {
                XmlSerializer xml = new XmlSerializer(loginInfo.GetType());
                using (Stream s = InfoFile.OpenRead())
                {
                    loginInfo = xml.Deserialize(s) as List <UserInfo>;
                }
            }
            var tList = new ObservableCollection <UserInfo>();

            foreach (var item in loginInfo)
            {
                tList.Add(new UserInfo
                {
                    AutomaticLogon = item.AutomaticLogon,
                    RememberPwd    = item.RememberPwd,
                    UserName       = CryptInfoHelper.GetDecrypte(item.UserName),
                    UserPwd        = CryptInfoHelper.GetDecrypte(item.UserPwd),
                    Tid            = item.Tid
                });
            }
            return(tList);
        }
Beispiel #2
0
 public FinanceResponse ChangePassword(UserChangePasswordRequest request)
 {
     service.ChagePassword(request.Id,
                           CryptInfoHelper.MD5Encode(CryptInfoHelper.GetDecrypte(request.OldPwd)),
                           CryptInfoHelper.MD5Encode(CryptInfoHelper.GetDecrypte(request.NewPwd)));
     return(CreateResponse(FinanceResult.SUCCESS));
 }
Beispiel #3
0
        public IdResponse Save(UserSaveRequest request)
        {
            var id       = request.Id;
            var userName = request.UserName;
            var password = CryptInfoHelper.GetDecrypte(request.PassWord);

            password = CryptInfoHelper.MD5Encode(password);
            if (id == 0)
            {
                service.AddUser(userName, password);
            }
            else
            {
                service.ModifyUser(id, userName, password);
            }

            return(new IdResponse {
                id = id
            });
        }
Beispiel #4
0
        public FinanceResponse Login(UserRequest request)
        {
            long userId   = 0;
            var  userName = request.UserName;
            var  password = CryptInfoHelper.GetDecrypte(request.PassWord);

            password = CryptInfoHelper.MD5Encode(password);

            userId = service.UserVerification(userName, password);
            if (userId == 0)
            {
                throw new FinanceException(FinanceResult.AUTHENTICATION_ERROR);
            }

            var tid = request.Tid;

            var token = OAuth2Handler.CreateToken(userId, userName, tid, DateTime.Now);

            return(new UserResponse {
                UserId = userId, UserName = userName, Token = token
            });
        }