Browse Source
Check user authentication before providing access token
pull/23381/head
maliming
7 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
7 additions and
0 deletions
-
framework/src/Volo.Abp.Http.Client.IdentityModel.Web/Volo/Abp/Http/Client/IdentityModel/Web/HttpContextAbpAccessTokenProvider.cs
|
|
|
@ -1,8 +1,10 @@ |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authentication; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Http.Client.Authentication; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
namespace Volo.Abp.Http.Client.IdentityModel.Web; |
|
|
|
|
|
|
|
@ -24,6 +26,11 @@ public class HttpContextAbpAccessTokenProvider : IAbpAccessTokenProvider, ITrans |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
if (!httpContext.RequestServices.GetRequiredService<ICurrentUser>().IsAuthenticated) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
return await httpContext.GetTokenAsync("access_token"); |
|
|
|
} |
|
|
|
} |
|
|
|
|