public APIJsonResult Login(LoginModel adminUserModel) { var adminUser = adminUserBLL.Find(user => user.Account == adminUserModel.Account && user.Status == UserStatusList.Active); if (adminUser == null || !UtilHelper.CompareString(adminUser.Password, EncryptHelper.EncryptString(adminUserModel.Password))) { return(Failed("Account and password do not match.")); } adminUser.LastLoginDate = DateTime.Now; adminUser.LastLoginIP = Request.ServerVariables.Get("Remote_Addr").ToString(); adminUser.Token = LoginManager.GenerateToken(); adminUser.TokenExpired = DateTime.Now.AddHours(2); adminUserBLL.SaveChanges(); LoginManager.SaveLoginUser(adminUser); return(Success("", new { Token = adminUser.Token, AdminUser = LoginManager.GetLoginUser(adminUser.Token) })); }