public static bool LoginUser(string username, string password, ref string message, bool rememberMe = false) { User user = new User() { UserId = 2 }; bool authenticated = UserBusinessService.LoginUser(username, password, out user, out message); if (authenticated) { AppSession.UserAccountSession = user; if (rememberMe) { User userAccountCookie = AppCookie.UserAccountCookie; if (userAccountCookie == null || userAccountCookie.Username != user.Username) { AppCookie.UserAccountCookie = user; } } else { AppCookie.UserAccountCookie = null; } } else { AppSession.UserAccountSession = null; AppCookie.UserAccountCookie = null; } return authenticated; }
public static bool Authenticate(string username, string password, out User user, bool loginViaApplicationIntegration = false) { user = null; if (!string.IsNullOrWhiteSpace(password)) { user = DataService.UserDataService.Authenticate(username, Encryptor.Encrypt(password)); if (user != null) { user.Password = Encryptor.Decrypt(user.Password); } } return user != null; }
public static bool LoginUser(string username, string password, out User user, out string message) { user = null; message = string.Empty; try { if (Authenticate(username, password, out user)) { return true; } else { message = "Invalid Username or Password."; return false; } } catch (Exception) { //errorMessage = ex.Message; message = "The system is down. Please try again."; return false; } }
public static int RegisterUser(User user, out long id) { int ret = InsertUser(user, out id); return ret; }
public static int InsertUser(User user, out long id) { user.Password = Encryptor.Encrypt(user.Password); return DataService.UserDataService.Insert(user, out id); }