public ApiMessage <object> LoginByToken(userinfo user) { var userData = _bll.LoginByToken(user); var outData = new ApiMessage <object> { Success = userData.Success, Msg = userData.Msg, MsgCode = userData.MsgCode }; if (!userData.Success) { return(outData); } var currentUser = UserVModel.FormatUser(userData.Data); var key = Encrypt.MD5(currentUser.Id + "_" + currentUser.UserType); outData.Data = new { Token = key, currentUser.UserName, currentUser.UserCode, currentUser.ImageUrl, currentUser.Id, currentUser.Phone, currentUser.IsMember, currentUser.PointAmount }; CacheHelper.SetCache(key, currentUser, new TimeSpan(0, 30, 0)); return(outData); }
/// <summary> /// 登录接口 /// </summary> /// <param name="ope"></param> /// <returns></returns> public ActionResult LoginOn(staff ope) { ope.PassWord = Encrypt.MD5(ope.PassWord); var user = _bll.LoginOn(ope); if (user.Success) { var currentUser = UserVModel.FormatUser(user.Data); var strUser = JsonConvert.SerializeObject(currentUser); //页面session Session["user"] = strUser; //webapi登录验证用 CacheHelper.SetCache(Encrypt.MD5(currentUser.Id + "_" + currentUser.UserType), currentUser); return(Redirect("/Home/Index")); } else { return(Redirect("/Login/Index?msg=" + user.Msg)); } }
public ApiMessage <object> LoginOn(staff user) { user.PassWord = Encrypt.MD5(user.PassWord); var userData = _bll.LoginOn(user); var outData = new ApiMessage <object> { Success = userData.Success, Msg = userData.Msg, MsgCode = userData.MsgCode }; if (!userData.Success) { return(outData); } var currentUser = UserVModel.FormatUser(userData.Data); var key = Encrypt.MD5(currentUser.Id + "_" + currentUser.UserType); outData.Data = new { token = key, UserName = currentUser.UserName, UserType = currentUser.UserType }; CacheHelper.SetCache(key, currentUser, new TimeSpan(0, 0, 30)); return(outData); }