Working version of registration and login phase.