Automatic login on register
Refactor code
Refactoring code