Example #1
0
        /// <summary>Tests if this IAccessToken is considered equal to another.</summary>
        /// <param name="other">The i access token to compare to this object.</param>
        /// <returns>true if the objects are considered equal, false if they are not.</returns>
        public virtual bool Equals(IAccessToken other)
        {
            if (this.GetIdentifier() != other.GetIdentifier())
            {
                return(true);
            }

            return(false);
        }
        /// <summary>Deletes the specified access token.</summary>
        /// <param name="accessToken">The access token.</param>
        /// <returns><c>True</c> if successful, <c>false</c> otherwise.</returns>
        public async Task <bool> DeleteAccessToken(IAccessToken accessToken)
        {
            using (var connection = await this.OpenConnection())
            {
                var rows =
                    await
                    connection.ExecuteAsync(
                        "DELETE FROM AccessTokens WHERE Token = @Id",
                        new { Id = accessToken.GetIdentifier() });

                return(rows == 1);
            }
        }
Example #3
0
        /// <summary>Deletes the specified access token.</summary>
        /// <param name="accessToken">The access token.</param>
        /// <returns><c>True</c> if successful, <c>false</c> otherwise.</returns>
        public async Task <bool> DeleteAccessToken(IAccessToken accessToken)
        {
            var db   = this.GetDatabase();
            var tran = db.CreateTransaction();

            // Remove items from indexes
            tran.HashDeleteAsync($"{this.Configuration.AccessTokenPrefix}:_index:client:{accessToken.ClientId}", accessToken.GetIdentifier());
            tran.HashDeleteAsync($"{this.Configuration.AccessTokenPrefix}:_index:redirecturi:{accessToken.RedirectUri}", accessToken.GetIdentifier());
            tran.HashDeleteAsync($"{this.Configuration.AccessTokenPrefix}:_index:subject:{accessToken.Subject}", accessToken.GetIdentifier());
            tran.SortedSetRemoveAsync($"{this.Configuration.AccessTokenPrefix}:_index:expires", accessToken.GetIdentifier());

            // Remove key
            tran.KeyDeleteAsync(accessToken.GetIdentifier());

            return(await tran.ExecuteAsync(CommandFlags.HighPriority));
        }