Working login code with correct db access.