Make the OWIN allow cross origin
来源:互联网 发布:java编程代码 编辑:程序博客网 时间:2024/05/22 10:51
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
using (AuthenticationRepository _repo = new AuthenticationRepository())
{
AppUser user = await _repo.GetUserForEmail(context.UserName, context.Password);
string username = string.Empty;
if (user == null)
{
user = _repo.GetUserForLoginUsingAppId(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "The user name or password is incorrect.");
return;
}
}
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
identity.AddClaim(new Claim(HandpickClaimTypes.UserId, user.Id.ToString()));
context.Validated(identity);
}
}
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
using (AuthenticationRepository _repo = new AuthenticationRepository())
{
AppUser user = await _repo.GetUserForEmail(context.UserName, context.Password);
string username = string.Empty;
if (user == null)
{
user = _repo.GetUserForLoginUsingAppId(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "The user name or password is incorrect.");
return;
}
}
var identity = new ClaimsIdentity(context.Options.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
identity.AddClaim(new Claim(HandpickClaimTypes.UserId, user.Id.ToString()));
context.Validated(identity);
}
}
0 0
- Make the OWIN allow cross origin
- Enable OWIN Cross-origin Request
- tomcat manager the Cross Origin Resource Sharing
- js跨域No 'Access-Control-Allow-Origin' header is present---js跨域英文翻译是cross-origin
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin is therefore no
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '***' is theref
- the 'access-control-allow-origin' header has a value 'http://localhost' but origin is null
- No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
- 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefor
- Access-Control-Allow-Origin
- Cross-Origin Resource Sharing
- cross-origin requests descripetion
- jsonp cross-origin requests
- AJAX跨越、JS跨越请求 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin
- XmlHttpRequesterror:OriginnullisnotallowedbyAccess-Control-Allow-Origin
- Access-Control-Allow-Origin 解决方法
- 跨域 Access-Control-Allow-Origin
- 默染江山——oc点语法、SEL
- 如何在多台服务器上共享Session(PHP/JSP/ASP.NET)以及单点登录(SSO)
- 暴风云视频sdk源码分享
- saving data - Saving Files
- win32 socket connect timeout
- Make the OWIN allow cross origin
- 关于匈牙利算法
- BZOJ 1190 HNOI2007 梦幻岛宝珠 动态规划
- hdu 4006 The kth great number
- VMware ESXI 5.5基础安装与网络配置
- uboot的链接基地址
- UVA 10767-Barcelona’s trams(DP+数学推导)
- Qt 防多开
- 如何解决ubuntu下找不到libgtk-x11-2.0.so.0