Skip to content

Instantly share code, notes, and snippets.

View acjh's full-sized avatar

Aaron Chong acjh

View GitHub Profile
@ismcagdas
ismcagdas / MyAppSession.cs
Last active April 27, 2021 13:18
How to add custom field to AbpSession in ASP.NET Core
//Define your own session and add your custom field to it
//Then, you can inject MyAppSession and use it's new property in your project.
public class MyAppSession : ClaimsAbpSession, ITransientDependency
{
public MyAppSession(
IPrincipalAccessor principalAccessor,
IMultiTenancyConfig multiTenancy,
ITenantResolver tenantResolver,
IAmbientScopeProvider<SessionOverride> sessionOverrideScopeProvider) :
base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider)
@hikalkan
hikalkan / AccountController.cs
Created January 13, 2016 16:25
Adding a new property to session
//Add new property to claims on login
private async Task SignInAsync(User user, ClaimsIdentity identity = null, bool rememberMe = false)
{
if (identity == null)
{
identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
}
identity.AddClaim(new Claim("Application_UserEmail", user.EmailAddress)); //SETTING NEW PROPERTY