Пример #1
0
        public async Task<int> ValidateCode(TokenRequest tokenRequest)
        {
            var codeData = await Cache.Get<AuthCodeData>(GetCacheKey(tokenRequest.Code));

            if (codeData == null)
            {
                throw new CallerException("Invalid code");
            }

            await Cache.Remove(GetCacheKey(tokenRequest.Code));

            if (codeData.ClientId != tokenRequest.ClientId)
            {
                throw new CallerException("Invalid client");
            }

            if (string.IsNullOrEmpty(codeData.CodeChallenge) || string.IsNullOrEmpty(tokenRequest.CodeVerifier))
            {
                throw new CallerException("Missing PKCE info");
            }

            VerifyCode(codeData.CodeChallenge, tokenRequest.CodeVerifier);

            return codeData.UserId;
        }
Пример #2
0
        public async Task <SiteSetting> CreateOrUpdateSetting(SiteSetting setting)
        {
            var existingSetting = await GetSetting(setting.SettingName);

            if (existingSetting == null)
            {
                setting = await CreateSetting(setting);
            }
            else
            {
                setting.SiteSettingId = existingSetting.SiteSettingId;

                setting = await UpdateSetting(setting);
            }

            await Cache.Remove(GetCacheKey(setting.SettingName));

            return(setting);
        }
Пример #3
0
        public async Task InvalidateSiteListCache()
        {
            await Cache.Remove(GetCacheKey(false));

            await Cache.Remove(GetCacheKey(true));
        }
Пример #4
0
        public async Task InvalidateUserRoleCache(int userId, bool isAdmin)
        {
            string key = GetCacheKey(userId, isAdmin);

            await Cache.Remove(key);
        }
Пример #5
0
        public async Task InvalidateListEntryCache(int listId)
        {
            await Cache.Remove(GetCacheKey(listId, false));

            await Cache.Remove(GetCacheKey(listId, true));
        }
Пример #6
0
        public async Task InvalidateUserCache(int userId)
        {
            var key = GetCacheKey(userId);

            await Cache.Remove(key);
        }
Пример #7
0
        public async Task InvalidateAppCache(string clientId)
        {
            var Key = GetCacheKey(clientId);

            await Cache.Remove(Key);
        }
        public async Task InvalidateUserProfilePropertiesCache(int userId)
        {
            await Cache.Remove(GetCacheKey(userId, true));

            await Cache.Remove(GetCacheKey(userId, false));
        }