Refactor code to automatically log user in after confirming