示例#1
0
        public async Task <ApplicationInfoDto> AddAppAsync(ApplicationInfoDto app)
        {
            var applicationEntity = this._mapper.Map <ApplicationEntity>(app);

            applicationEntity.Id       = this._idGenerator.NewId();
            applicationEntity.AppScret = this._encryptHelper.GenerateSalt(10);
            await this._appRepository.InsertAsync(applicationEntity);

            return(app);
        }
示例#2
0
 public Task EditAsync(long id, ApplicationInfoDto value)
 {
     return(this._appRepository.UpdateAsync(() => new ApplicationEntity
     {
         AppName = value.AppName,
         AppCode = value.AppCode,
         Descript = value.Descript,
         CallbackUrl = value.CallbackUrl
     }, x => x.Id == id));
 }
        public async Task <ApplicationInfoDto> AddAppAsync(ApplicationInfoDto app)
        {
            var applicationEntity = this._mapper.Map <ApplicationEntity>(app);

            var pwd = this._encryptHelper.GenerateSalt(10);

            var userEntity = UserEntity.NewUser(this._idGenerator.NewId(), app.AppCode, pwd, app.AppName, this._encryptHelper);

            userEntity.AccountType = Domain.Enums.AccountType.Application;

            applicationEntity.Id        = this._idGenerator.NewId();
            applicationEntity.Account   = userEntity;
            applicationEntity.AppUserId = userEntity.Id;
            //applicationEntity.AppScret = this._encryptHelper.GenerateSalt(10);
            await this._appRepository.InsertAsync(applicationEntity);

            app.AppScret = pwd;
            return(app);
        }
        private async Task <AuthenticateResult> AppTokenVerify(string token)
        {
            var loginService = this.context.RequestServices.GetService <ILoginService>();
            var tokenEntity  = await loginService.GetTokenEntityByTokenAsync(token);

            var appService         = this.context.RequestServices.GetService <IApplicationService>();
            ApplicationInfoDto app = await appService.GetOneAsync(tokenEntity.UserId);

            if (tokenEntity == null)
            {
                return(AuthenticateResult.Fail("token error"));
            }
            if (tokenEntity.IsExpire())
            {
                return(AuthenticateResult.Fail("token expired"));
            }
            var identity  = new ApplicationIdentity(app);
            var principal = new EasyRbacPrincipal(identity);

            return(AuthenticateResult.Success(new AuthenticationTicket(principal, "app")));
        }
示例#5
0
        public Task EditAsync(long id, ApplicationInfoDto value)
        {
            var appEntity = this._mapper.Map <ApplicationEntity>(value);

            appEntity.CallbackConfigs.ForEach(x =>
            {
                if (x.Id == -1)
                {
                    x.Id    = this._idGenerator.NewId();
                    x.AppId = value.Id;
                }
            });
            return(this._appRepository.UpdateApplicationConfigInfo(appEntity));

            //return this._appRepository.UpdateAsync(() => new ApplicationEntity
            //{
            //    AppName = value.AppName,
            //    AppCode = value.AppCode,
            //    Descript = value.Descript,
            //    CallbackUrl = value.CallbackUrl
            //}, x => x.Id == id);
        }
示例#6
0
 public Task Put(long id, [FromBody] ApplicationInfoDto value)
 {
     value.CallbackConfigs?.ForEach(x => x.CreateBy = this.User.Identity.Name);
     return(this._applicationService.EditAsync(id, value));
 }
 public Task Put(long id, [FromBody] ApplicationInfoDto value)
 {
     return(this._applicationService.EditAsync(id, value));
 }
 public Task <ApplicationInfoDto> Post([FromBody] ApplicationInfoDto app)
 {
     return(this._applicationService.AddAppAsync(app));
 }