Properly implemented login logic (backend)