自定义Mvc5 Owin 验证
public class AuthIn : IUserAuthenticate { public static ApplicationUserManager UserManager { get { return HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>(); } } private IAuthenticationManager AuthenticationManager { get { return HttpContext.Current.GetOwinContext().Authentication; } } public void CurUserLoginOut() { AuthenticationManager.SignOut(); } public bool GetUserIsAuthenticated() { return HttpContext.Current.User.Identity.IsAuthenticated; } public void SignUserLogin(string strUserName, Dictionary<string, string> extDatas) { ApplicationUser user = UserManager.FindByName(strUserName); if (user == null) { user = new ApplicationUser { UserName = strUserName, Email = extDatas["Email"] }; IdentityResult result = Task.Factory.StartNew(s => { return ((ApplicationUserManager)s).CreateAsync(user); }, UserManager).Unwrap().GetAwaiter().GetResult(); if (!result.Succeeded) { HttpContext.Current.Response.Write("Error on Create User"); return; } } ClaimsIdentity indentiy = Task.Factory.StartNew(s => { return user.GenerateUserIdentityAsync(((ApplicationUserManager)s)); }, UserManager).Unwrap().GetAwaiter().GetResult(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = false }, indentiy); } }
自定义Mvc5 Owin 验证的更多相关文章
- WCF 安全性之 自定义用户名密码验证
案例下载 http://download.csdn.net/detail/woxpp/4113172 客户端调用代码 通过代理类 代理生成 参见 http://www.cnblogs.com/woxp ...
- 【WCF】Silverlight+wcf+自定义用户名密码验证
本文摘自 http://www.cnblogs.com/virusswb/archive/2010/01/26/1656543.html 在昨天的博文Silverlight3+wcf+在不使用证书的情 ...
- jquery.validate.js之自定义表单验证规则
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- Spring MVC 项目搭建 -6- spring security 使用自定义Filter实现验证扩展资源验证,使用数据库进行配置
Spring MVC 项目搭建 -6- spring security使用自定义Filter实现验证扩展url验证,使用数据库进行配置 实现的主要流程 1.创建一个Filter 继承 Abstract ...
- Spring-Security 自定义Filter完成验证码校验
Spring-Security的功能主要是由一堆Filter构成过滤器链来实现,每个Filter都会完成自己的一部分工作.我今天要做的是对UsernamePasswordAuthenticationF ...
- ASP.NET Core的JWT的实现(自定义策略形式验证).md
既然选择了远方,便只顾风雨兼程 __ HANS许 在上篇文章,我们讲了JWT在ASP.NET Core的实现,基于中间件来实现.这种方式有个缺点,就是所有的URL,要嘛需要验证,要嘛不需要验证,没有办 ...
- layui 自定义表单验证的几个实例
*注:使用本方法请先引入layui依赖的layu.js和layui.css 1.html <input type="text" name="costbudget&q ...
- 基于struts2框架-自定义身份证号验证器
自定义拦截器的步骤: 1.定义一个验证器的类: > 自定义的验证器都需要实现 Validator接口. > 可以选择继承 ValidatorSupport 或 FieldValidato ...
- Angular5+ 自定义表单验证器
Angular5+ 自定义表单验证器 Custom Validators 标签(空格分隔): Angular 首先阐述一下遇到的问题: 怎样实现"再次输入密码"的验证(两个cont ...
随机推荐
- 刷固件Layer1到手机FLASH(硬刷)
开头: 注意:本文章并不是做GSM 嗅探必须的,平时我们刷机叫软刷是刷到内存里面的,断电就消失了,这个是硬刷,刷到flash里面的,断电不消失,开机就运行的. 本文章经过作者实测可行,这只是单个应用程 ...
- PP
- 并列div自动等高
并列div自动等高 方法一:css控制 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- Best Sequence_DFS&&KMp
Description The twenty-first century is a biology-technology developing century. One of the most att ...
- java作业4
(一) 请查看String.equals()方法的实现代码,注意学习其实现方法.(发表到博客作业上) (二) 整理String类的Length().charAt(). getChars().rep ...
- 通过.htaccess文件让Magento加速
Magento提速的方法很多,通 过.htaccess文件开启GZip压缩可以非常明显的让Magento加速.在Magento初始安装中已经包含了.htaccess文件,我们只需 要把.htacces ...
- js实现简单易用的上下无缝滚动效果
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- jellyfish K-mer analysis and genome size estimate
http://www.cbcb.umd.edu/software/jellyfish/ http://www.genome.umd.edu/jellyfish.html https://githu ...
- 如何用 freebayes call SNP
1,软件介绍 FreeBayes is a Bayesian genetic variant detector designed to find small polymorphisms, specif ...
- linux/windows 下kill某个pid的进程
[linux环境] 方法1:截取进程pid,再kill ps -ef | grep java.endorsed.dirs | grep -v grep | cut -c10-15 | xargs ki ...