Login is functional. TODO: refactoring