示例#1
0
        /// <summary>
        /// Creates or updates an authorization code entity.
        /// </summary>
        /// <param name="code">The authorization code entity to save.</param>
        /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param>
        /// <returns>The change method result.</returns>
        public Task <ChangeMethods> SaveAsync(AuthorizationCodeEntity code, CancellationToken cancellationToken = default)
        {
            var context = GetContext();

            return(DbResourceEntityExtensions.SaveAsync(context.Codes, context.SaveChangesAsync, code, cancellationToken));
        }
示例#2
0
 /// <summary>
 /// Creates or updates an authorization code entity.
 /// </summary>
 /// <param name="code">The authorization code entity to save.</param>
 /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param>
 /// <returns>The change method result.</returns>
 public Task <ChangeMethods> SaveAsync(AuthorizationCodeEntity code, CancellationToken cancellationToken = default)
 {
     return(SaveAsync(codes, code, cancellationToken));
 }
示例#3
0
        /// <summary>
        /// Gets a client credential by app identifier.
        /// </summary>
        /// <param name="provider">The provider name or url.</param>
        /// <param name="code">The authorization code.</param>
        /// <param name="cancellationToken">The optional token to monitor for cancellation requests.</param>
        /// <returns>The user entity matched if found; otherwise, null.</returns>
        public Task <AuthorizationCodeEntity> GetAuthorizationCodeByCodeAsync(string provider, string code, CancellationToken cancellationToken = default)
        {
            var codeHash = AuthorizationCodeEntity.ComputeCodeHash(code);

            return(GetContext(true).Codes.FirstOrDefaultAsync(ele => ele.CodeEncrypted == codeHash && ele.ServiceProvider == provider, cancellationToken));
        }