Пример #1
0
        /// <inheritdoc />
        public async Task SetTokenAsync(TUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
        {
            var id = IdentityUserAuthToken.GetWellKnownId(_store, user.Id, loginProvider, name);

            ThrowIfDisposedOrCancelled(cancellationToken);

            using (IAsyncDocumentSession session = _store.OpenAsyncSession())
            {
                var existingOrNull = await session.LoadAsync <IdentityUserAuthToken>(id);

                if (existingOrNull == null)
                {
                    existingOrNull = new IdentityUserAuthToken
                    {
                        Id            = id,
                        LoginProvider = loginProvider,
                        Name          = name,
                        UserId        = user.Id,
                        Value         = value
                    };
                    await session.StoreAsync(existingOrNull);
                }

                existingOrNull.Value = value;

                await session.SaveChangesAsync(cancellationToken);
            }
        }
Пример #2
0
        /// <inheritdoc />
        public Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
        {
            var id = IdentityUserAuthToken.GetWellKnownId(DbSession.Advanced.DocumentStore, user.Id, loginProvider, name);

            DbSession.Delete(id);

            return(Task.CompletedTask);
        }
Пример #3
0
        /// <inheritdoc />
        public async Task RemoveTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
        {
            var id = IdentityUserAuthToken.GetWellKnownId(_store, user.Id, loginProvider, name);

            using (IAsyncDocumentSession session = _store.OpenAsyncSession())
            {
                session.Delete(id);
                await session.SaveChangesAsync(cancellationToken);
            }
        }
Пример #4
0
        /// <inheritdoc />
        public async Task <string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
        {
            var id          = IdentityUserAuthToken.GetWellKnownId(DbSession.Advanced.DocumentStore, user.Id, loginProvider, name);
            var tokenOrNull = await DbSession.LoadAsync <IdentityUserAuthToken>(id);

            if (tokenOrNull == null)
            {
                return(null);
            }

            return(tokenOrNull.Value);
        }
Пример #5
0
        /// <inheritdoc />
        public async Task <string> GetTokenAsync(TUser user, string loginProvider, string name, CancellationToken cancellationToken)
        {
            var id = IdentityUserAuthToken.GetWellKnownId(_store, user.Id, loginProvider, name);

            using (IAsyncDocumentSession session = _store.OpenAsyncSession())
            {
                var tokenOrNull = await session.LoadAsync <IdentityUserAuthToken>(id);

                if (tokenOrNull == null)
                {
                    return(null);
                }

                return(tokenOrNull.Value);
            }
        }