public class ApplicationUser :IdentityUser
{
public string AuthenticationType { get; set; }
public bool IsAuthenticated { get; set; }
public string Name { get; set; }
}
///
/// 登录
///
[HttpPost]
[AllowAnonymous]
public async Task Login(ReqLoginModel req)
{
var json = new JsonResultModel();
if (ModelState.IsValid)
{
var result = await _signInManager.PasswordSignInAsync(req.UserName, req.Password, isPersistent: true, lockoutOnFailure: false);
if (result.Succeeded)
{
json.code = "200";
json.message = "登录成功";
}
else
{
json.code = "400";
json.message = "登录失败";
}
if (result.IsLockedOut)
{
json.code = "401";
json.message = "账户密码已错误3次,账户被锁定,请30分钟后再尝试";
}
}
else
{
var errorMessges = ModelState.GetErrorMessage();
json.code = "403";
json.message = string.Join(",", errorMessges);
}
return json.ToJsonResult();
}
///
/// 登出
///
///
[HttpPost]
public async Task LogOut()
{await _signInManager.SignOutAsync();
var json = new JsonResultModel()
{
code = "200",
data = null,
message = "登出成功",
remark = string.Empty
};
return json.ToJsonResult();
}
四、使用Identity配置
在 ConfigureServices 方法中加入
services.Configure(options =>
{
// 密码配置
options.Password.RequireDigit = false;//是否需要数字(0-9).
options.Password.RequiredLength = 6;//设置密码长度最小为6
options.Password.RequireNonAlphanumeric = false;//是否包含非字母或数字字符。
options.Password.RequireUppercase = false;//是否需要大写字母(A-Z).
options.Password.RequireLowercase = false;//是否需要小写字母(a-z).
//options.Password.RequiredUniqueChars = 6;
// 锁定设置
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(30);//账户锁定时长30分钟
options.Lockout.MaxFailedAccessAttempts = 3;//10次失败的尝试将账户锁定
//options.Lockout.AllowedForNewUsers = true;
// 用户设置
options.User.RequireUniqueEmail = false; //是否Email地址必须唯一
});
services.ConfigureApplicationCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = true;
//options.Cookie.Expiration = TimeSpan.FromMinutes(30);//30分钟
options.Cookie.Expiration = TimeSpan.FromHours(12);//12小时
options.LoginPath = "/api/Account/NotLogin"; // If the LoginPath is not set here, ASP.NET Core will default to /Account/Login
//options.LogoutPath = "/api/Account/Logout"; // If the LogoutPath is not set here, ASP.NET Core will default to /Account/Logout
//options.AccessDeniedPath = "/Account/AccessDenied"; // If the AccessDeniedPath is not set here, ASP.NET Core will default to /Account/AccessDenied
options.SlidingExpiration = true;
});
Enum是计算机编程语言中的一种数据类型---枚举类型。 在实际问题中,有些变量的取值被限定在一个有限的范围内。 例如,一个星期内只有七天 我们通常这样实现上面的定义:
public String monday;
public String tuesday;
public String wensday;
public String thursday
java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'add' - neither qualifier match nor bean name match!
网上找了好多的资料没能解决,后来发现:项目中使用的是xml配置的方式配置事务,但是
原文:http://stackoverflow.com/questions/15585602/change-limit-for-mysql-row-size-too-large
异常信息:
Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAM
/**
* 格式化时间 2013/6/13 by 半仙 [email protected]
* 需要 pad 函数
* 接收可用的时间值.
* 返回替换时间占位符后的字符串
*
* 时间占位符:年 Y 月 M 日 D 小时 h 分 m 秒 s 重复次数表示占位数
* 如 YYYY 4占4位 YY 占2位<p></p>
* MM DD hh mm
在使用下面的命令是可以通过--help来获取更多的信息1,查询当前目录文件列表:ls
ls命令默认状态下将按首字母升序列出你当前文件夹下面的所有内容,但这样直接运行所得到的信息也是比较少的,通常它可以结合以下这些参数运行以查询更多的信息:
ls / 显示/.下的所有文件和目录
ls -l 给出文件或者文件夹的详细信息
ls -a 显示所有文件,包括隐藏文
Spring Tool Suite(简称STS)是基于Eclipse,专门针对Spring开发者提供大量的便捷功能的优秀开发工具。
在3.7.0版本主要做了如下的更新:
将eclipse版本更新至Eclipse Mars 4.5 GA
Spring Boot(JavaEE开发的颠覆者集大成者,推荐大家学习)的配置语言YAML编辑器的支持(包含自动提示,