Login validation function, cleanup