public async Task <ActionResult <UserLogin> > SignInUser(UserSignin data) { _logger.LogInformation("Signing user in"); var user = await _userService.SignInUser(data.EmailAddress, data.Password); if (user != null) { var claims = new[] { new Claim(ClaimTypes.Role, "Some user role"), new Claim(ClaimTypes.Name, user.EmailAddress), new Claim("CustomUserIdentifier", user.Id.ToString()) }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration.GetSection("jwt")["key"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512); var token = new JwtSecurityToken( _configuration.GetSection("jwt")["issuer"], _configuration.GetSection("jwt")["audience"], claims, expires: DateTime.Now.AddDays(1), signingCredentials: creds); _logger.LogInformation("Signed user in, sending back his login data"); return(new UserLogin { JwtToken = new JwtSecurityTokenHandler().WriteToken(token), EmailAddress = user.EmailAddress, Id = user.Id }); } return(Unauthorized()); }
public IHttpActionResult UserSignIn() { UserSignin us = null; UserSigninfo ui = null; string userID = GetUserID(); if (String.IsNullOrEmpty(userID)) { return(Error("用户ID不能为空")); } int type = 0; type = ent.getUserAttSetType(userID); if (type == 0) { us = ent.UserSignIn(userID); return(Ok(us)); } else { ui = ent.UserSignOuterInfo(userID); return(Ok(ui)); } }
public IHttpActionResult UserSignInByEF() { string userID = GetUserID(); if (String.IsNullOrEmpty(userID)) { return(Error("用户ID不能为空")); } UserSignin us = null; UserSigninfo ui = null; for (int i = 0; i < 1000; i++) { int type = 0; type = ent.getUserAttSetType(userID); if (type == 0) { us = ent.UserSignInByEF(userID); } else { ui = ent.UserSignOuterInfoByEF(userID); } } if (us != null) { return(Ok(us)); } else { return(Ok(ui)); } }
public async Task <ActionResult <UserLogin> > SignInUser(UserSignin data) { var login = await _userService.SignInUser(data.EmailAddress, data.Password); if (login != null) { return(login); } return(Unauthorized()); }
/// <summary> /// 移动端登陆 /// </summary> /// <param name="para"></param> /// <returns></returns> public override ActionResult <UserView> APPUserSignin(UserSignin para) { var rpsaccount = _work.Repository <AccountInfo>(); var account = rpsaccount.GetModel(q => q.AccountCode == para.AccountCode); if (account == null) { throw new Exception("用户名密码或账套号错误"); } if (account.State == (int)PublicEnum.AccountState.Closed || account.ValidDate <= DateTime.Now) { throw new Exception("账套已过期或已关闭"); } Core.Model.AppUserDB userdb = new AppUserDB() { DBName = account.DBName, DBPwd = account.DBPwd, DBServer = account.DBServer, DBUid = account.DBUid }; Unitwork.SetUserDB(userdb); var sresult = base.APPUserSignin(para); if (sresult.data != null && sresult.state == 200) { var user = sresult.data.UserInfo; user.TokenValidTime = DateTime.Now.AddMinutes(account.TokenValidTimes); _work.Repository <Core.Model.DB.Auth_User>().Update(user); _work.Commit(); sresult.data.AccountID = account.ID; sresult.data.AccountCode = account.AccountCode; sresult.data.AccountName = account.AccountName; sresult.data.Principal = account.Principal; sresult.data.ShortName = account.ShortName; sresult.data.Tel = account.Tel; } return(sresult); }
public ActionResult <UserView> APPUserSignin(UserSignin para) { return(authbll.APPUserSignin(para)); }
public ActionResult <UserView> UserSignin(UserSignin para) { LogContent = "用户登陆,用户:" + para.Login; return(bll.UserSignin(para)); }