Example #1
0
        private async Task <TResponse <bool> > Update(int userId,
                                                      PersistedGrantDto persistedGrant)
        {
            try
            {
                var result = await WriteRepository.ExecuteAsync(SqlQuery.PERSISTED_GRANT_UPDATE, new
                {
                    persistedGrant.ClientId,
                    persistedGrant.SubjectId,
                    persistedGrant.Key,
                    persistedGrant.Data,
                    persistedGrant.Type,
                    persistedGrant.CreationTime,
                    persistedGrant.Expiration,
                    UserUpdated = userId
                });

                if (result.IsSuccess)
                {
                    if (result.Data > 0)
                    {
                        return(await Ok(true));
                    }

                    return(await Fail <bool>(string.Format(ErrorEnum.SqlQueryCanNotExecute.GetStringValue(), "PERSISTED_GRANT_UPDATE")));
                }

                return(await Fail <bool>(result.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }
Example #2
0
        public async Task <ResultResponseDto> StoreAsync(PersistedGrantDto dto)
        {
            if (!dto.IsValid(Logger, LogLevel.Error))
            {
                return(Result.ReFailure <ResultResponseDto>("请求参数错误", ResultCodes.InvalidParameter));
            }
            //转换为存储对象
            PersistedGrant grant = null;

            if (base.State == null)
            {
                //添加令牌
                grant = Mapper.Map <PersistedGrant>(dto);
                grant.SetId(this.GetPrimaryKeyString());
            }
            else
            {
                grant = base.State.Clone <PersistedGrant>();
                grant = Mapper.Map(dto, grant);
            }
            if (!grant.IsValid(Logger, LogLevel.Error))
            {
                return(Result.ReFailure <ResultResponseDto>("请求参数错误", ResultCodes.InvalidParameter));
            }
            base.State = grant;
            await base.WriteStateAsync();

            return(Result.ReSuccess <ResultResponseDto>());
        }
Example #3
0
        public async Task <IActionResult> PersistedGrantDelete(PersistedGrantDto grant)
        {
            await _persistedGrantService.DeletePersistedGrantAsync(grant.Key);

            SuccessNotification(_localizer["SuccessPersistedGrantDelete"], _localizer["SuccessTitle"]);

            return(RedirectToAction(nameof(PersistedGrants)));
        }
Example #4
0
        public async Task <IActionResult> PersistedGrantDelete(PersistedGrantDto grant)
        {
            await _persistedGrantService.DeletePersistedGrantAsync(grant.Key);



            return(Success());
        }
Example #5
0
        public async Task <TResponse <bool> > Save(int userId,
                                                   PersistedGrantDto persistedGrant)
        {
            try
            {
                var existPersistedGrant = await GetByKey(persistedGrant.Key);

                if (existPersistedGrant.IsSuccess)
                {
                    TResponse <bool> result;

                    if (existPersistedGrant.Data != null)
                    {
                        //da ton tai, cap nhat lai du lieu
                        result = await Update(userId, persistedGrant);
                    }
                    else
                    {
                        //chua ton tai, them moi
                        result = await Insert(userId, persistedGrant);
                    }

                    if (result != null)
                    {
                        if (result.IsSuccess)
                        {
                            return(await Ok(true));
                        }

                        return(await Fail <bool>(result.Message));
                    }

                    return(await Fail <bool>(string.Format(ErrorEnum.SqlQueryCanNotExecute.GetStringValue(), "Can not insert or update persisted grant")));
                }

                return(await Fail <bool>(existPersistedGrant.Message));
            }
            catch (Exception exception)
            {
                return(await Fail <bool>(exception));
            }
        }
Example #6
0
 public PersistedGrantIdentityRequestedEvent(PersistedGrantDto persistedGrant)
 {
     PersistedGrant = persistedGrant;
 }
Example #7
0
        public async Task OnGetAsync()
        {
            var dataDto = await _persistedGrantAppService.GetAsync(Id);

            PersistedGrantUpdateDto = ObjectMapper.Map <PersistedGrantDto, PersistedGrantDto>(dataDto);
        }