Check if the user exists locally and in moodle
Fixed some pep8 warnings.
Redirected logged in moodle users to home and made some pep8 fixes.