Browse Source
Merge pull request #18979 from abpframework/RememberMe-patch
Add `RememberMe` claim during password flow.
pull/19010/head
Sinan Öztürk
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
9 additions and
0 deletions
-
modules/openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Controllers/TokenController.Password.cs
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Security.Claims; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authentication; |
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
@ -14,6 +15,7 @@ using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Identity; |
|
|
|
using Volo.Abp.Identity.Settings; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.Abp.Security.Claims; |
|
|
|
using Volo.Abp.Settings; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Volo.Abp.Validation; |
|
|
|
@ -342,6 +344,13 @@ public partial class TokenController |
|
|
|
// will be used to create an id_token, a token or a code.
|
|
|
|
var principal = await SignInManager.CreateUserPrincipalAsync(user); |
|
|
|
|
|
|
|
var rememberMe = request.GetParameter("RememberMe").ToString(); |
|
|
|
if (!rememberMe.IsNullOrWhiteSpace() && bool.TryParse(rememberMe, out var rememberMeValue) && rememberMeValue) |
|
|
|
{ |
|
|
|
var claim = new Claim(AbpClaimTypes.RememberMe, true.ToString()).SetDestinations(OpenIddictConstants.Destinations.AccessToken); |
|
|
|
principal.Identities.FirstOrDefault()?.AddClaim(claim); |
|
|
|
} |
|
|
|
|
|
|
|
principal.SetScopes(request.GetScopes()); |
|
|
|
principal.SetResources(await GetResourcesAsync(request.GetScopes())); |
|
|
|
|
|
|
|
|