Example #1
0
        public async Task <IEnumerable <TokenStoreHeader> > GetTokensAsync(
            CancellationToken cancellationToken)
        {
            var path    = SettingsStore.GetUserDirectory("auth_token");
            var entries = new List <TokenStoreHeader>();

            foreach (FileInfo?file in new DirectoryInfo(path).GetFiles())
            {
                TokenStoreModel?authData = await _authTokenStore.GetAsync(
                    file.Name,
                    cancellationToken);

                if (authData is null)
                {
                    continue;
                }

                IdentityRequestItem?request = await TryGetIdentityRequest(
                    authData,
                    cancellationToken);

                TokenStoreHeader entry = ToTokenHeader(authData, request);

                entries.Add(entry);
            }

            return(entries);
        }
Example #2
0
        public async Task<RefreshStoredTokenPayload> RefreshStoredTokenAsync(
            [Service] IAuthTokenStoreReader tokenStore,
            string id,
            CancellationToken cancellationToken)
        {
            TokenStoreHeader header = await tokenStore.RefreshAsync(id, cancellationToken);

            return new RefreshStoredTokenPayload(header);
        }
Example #3
0
        private static TokenStoreHeader ToTokenHeader(
            TokenStoreModel authData,
            IdentityRequestItem?request)
        {
            var header = new TokenStoreHeader(
                authData.Name,
                request?.Name ?? authData.Name,
                authData.CreatedAt);

            if (request is { })
Example #4
0
 public RefreshStoredTokenPayload(TokenStoreHeader header)
 {
     Header = header;
 }