public static bool validate_user(Guid?applicationId, string username, string password) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(false); } string savedPass = string.Empty, savedSalt = string.Empty; UsersController.get_current_password(applicationId, username, ref savedPass, ref savedSalt); bool loggedIn = false; int failedLoginAttemptsCount = 0; if (string.IsNullOrEmpty(savedPass) || string.IsNullOrEmpty(savedSalt)) { return(false); } password = PublicMethods.verify_string(password); loggedIn = UserUtilities.encode_password(password, savedSalt) == savedPass; failedLoginAttemptsCount = UsersController.login_attempt(applicationId, username, loggedIn); if (!loggedIn && failedLoginAttemptsCount >= RaaiVanSettings.AllowedConsecutiveFailedLoginAttempts(applicationId)) { UsersController.lock_user(applicationId, username); } return(loggedIn); }
public static void get_current_password(Guid?applicationId, string username, ref string password, ref string passwordSalt) { Guid?userId = UsersController.get_user_id(applicationId, username); if (userId.HasValue) { UsersController.get_current_password(userId.Value, ref password, ref passwordSalt); } }