-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DispatchGlobal/Dispatch will 400 error when execute HttpContext.SignInAsync before. #80
Comments
Hi! Unfortunately I can't reproduce it. In the test project I called |
hydro-test-dispatch.zip |
The problem is with anti-forgery token. After signing in, it changes, but Hydro still has the previous one. Then we try to trigger an event with obsolete token. Usually when users refresh the page after login, this issues doesn't occur, because the tokens are retrieved again on page reload. Hydro already has a mechanism to auto-refresh the token, but it happens when server returns first 400 status code. So it first fails and then it gets refreshed. For now, a dirty workaround would be to call your event twice: DispatchGlobal(new UserEvent()); // fail and refresh token
DispatchGlobal(new UserEvent()); // will work I will address this issue, so this hack is not needed :) |
I just need update userinfo header when user logoin success,but when I execute HttpContext.SignInAsync and DispatchGlobal will 400 error ,In other cases DispatchGlobal is normal.
var claims = new List
{
new Claim(ClaimTypes.Name, "111"),
new Claim(ClaimTypes.Role, "User")
};
var claimsIdentity = new ClaimsIdentity(claims, AppConst.AuthenticationScheme);
await HttpContext.SignInAsync(AppConst.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity));
DispatchGlobal(new UserEvent());
DispatchGlobal will receive 400 error.
The text was updated successfully, but these errors were encountered: