AbpSession not loggedin using WinForm
See original GitHub issue- Abp 2.3.0 + AbpZero
- .Net Framework
- User did not login
I have an issue using abp with winform. I create a form to login and I’m able to login
var loginResult = await GetLoginResultAsync(userTxt.Text, passTxt.Text, "Default");
// The call is below
private async Task<AbpLoginResult<Tenant, User>> GetLoginResultAsync(string usernameOrEmailAddress, string password, string tenancyName)
{
Globals.LoginResult = await _logInManager.LoginAsync(usernameOrEmailAddress, password, tenancyName);
The problem is that my AbpSession is still not logged in. Looking on web mobule I see that I need to set the IPrincipalAccessor and I try to set it with admin data but not working
Configuration.ReplaceService<IPrincipalAccessor, WinFormPrincipalAccessor>(DependencyLifeStyle.Transient);
//Configuration.ReplaceService<IPrincipalAccessor, HttpContextPrincipalAccessor>(DependencyLifeStyle.Transient);
// My Principal
public class WinFormPrincipalAccessor : DefaultPrincipalAccessor
{
private ClaimsPrincipal _princ;
public override ClaimsPrincipal Principal
{
get
{
var id = new GenericIdentity("admin");
id.AddClaim(new Claim(AbpClaimTypes.TenantId, "1"));
id.AddClaim(new Claim("nameidentifier","2"));
id.AddClaim(new Claim("name", "admin"));
var role = new string[1] { "Admin" };
_princ = new GenericPrincipal(id, role);
return _princ;
}
}
public void SetPrincipal(object user)
{
}
}
So how can I fill my Principal data like HttpContext for Web? Is it a bug or missing somenthing?
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
AbpSession.UserId is null right after login
Then I configured it as default IAbpSession in MyApp.Console module. Here it is the code: [DependsOn( typeof(MyAppApplicationModule), typeof( ...
Read more >[Solved]-AbpSession.UserId is null right after login-C#
tenantid and loginresult.user.id . you can also override the current session values with the logged-in user: var loginresult = await _loginmanager.loginasync(..
Read more >How do I create a login session in C#? - CodeProject
There is no such thing as a "session" in WinForms: it's a construct that is needed in websites because you may have multiple...
Read more >[Solved] Session in Windows Form
I am building a desktop application.I have made a log in form. First i login to a user and than without log out...
Read more >Overriding Current Session Values
IAbpSession is also fully integrated and used by other structures in ASP. ... or null if there is no current tenant (in case...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
after
var loginResult = await GetLoginResultAsync(userTxt.Text, passTxt.Text, "Default");
just setThread.CurrentPrincipal = new ClaimsPrincipal(loginResult.Identity);
and then you can use AbpSession as normal . ps: no need to define “WinFormPrincipalAccessor”, just use buildin “DefaultPrincipalAccessor”@rqx110 I try to use your solution but I need to configure
in web module I use this
in win form I need to init the IAuthenticationManager