Пример #1
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public virtual PasswordDto Reset(string name, string password)
        {
            var result = new PasswordDto
            {
                IsTimeout = CheckTemporary(name)
            };

            if (result.IsTimeout)
            {
                return(result);
            }
            var account = GetAccount(name);

            if (account == null)
            {
                result.Result = false;
                return(result);
            }
            SetSaveAccount(account, password);
            var unitofworks = AccountDomainService.Handle(account);

            if (unitofworks == null)
            {
                result.Result = false;
                result.Errors = account.Errors;
                return(result);
            }
            var locker = new LockerEntity
            {
                Name = account.Name,
                Tag  = IdentityEntity.LockTag
            };

            unitofworks.AddList(LockerDomainService.Release(locker));
            result.Result = Winner.Creator.Get <IContext>().Commit(unitofworks);
            result.Errors = locker.Errors;
            return(result);
        }
Пример #2
0
 /// <summary>
 /// 执行
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public virtual EmailDto Action(EmailDto dto)
 {
     dto.Account = GetAccount(dto.AccountId);
     if (dto.Account == null)
     {
         return(dto);
     }
     dto.Result = CodeValidateDomainService.ValidateCode(string.Format("{0}{1}", Tag, dto.Action), dto.AccountId.ToString(), CodeType.Email, dto.Code);
     if (dto.Action == "Bind")
     {
         dto.Account.AccountIdentites = new List <AccountIdentityEntity>();
         if (dto.Email != dto.Account.Email)
         {
             var accountIdentiy = GetAccountIdentity(dto.Account.Email);
             accountIdentiy.SaveType = SaveType.Remove;
             dto.Account.AccountIdentites.Add(accountIdentiy);
         }
         dto.Account.Email         = dto.Email;
         dto.Account.IsActiveEmail = true;
         dto.Account.SetProperty(it => it.Email);
         dto.Account.SetProperty(it => it.IsActiveEmail);
         dto.Account.SaveType = SaveType.Modify;
         dto.Account.AccountIdentites.Add(new AccountIdentityEntity
         {
             Account  = dto.Account,
             Name     = "Email",
             Number   = dto.Email,
             SaveType = SaveType.Add
         });
         var unitofworks = AccountDomainService.Handle(dto.Account);
         dto.Result = Winner.Creator.Get <IContext>().Commit(unitofworks);
         dto.Errors = dto.Errors;
     }
     dto.SetAction();
     return(dto);
 }