Handle all cases of login.
Firstly refactor the code to move all the post login mechanisms to a
function of its own.
Then add support to redirect the user if the login was attempted from
logout page.
Finally if the post response we got contains html, it is not a valid
JSON, which means the login failed. In this case catch the exception
and show the login error.
# use glob syntax.
syntax: glob
*.pyc
*.zip
*~
.project
.pydevproject
app.yaml
build
tests/coverageResults
*,cover
tests/.coverage
*.git
*.egg-info
eggs
parts
.installed.cfg
bin
develop-eggs
.gitignore
.DS_Store
.settings
.*.swp
*.egg
*.egg-link
*.svn*
*.wpr
.installed.cfg
src/*
parts
downloads
.xvpics*
.project
pytask/local.py
pytask/pytask.egg-info
pytask/static/media
apache/*
*.swp
*.bak
*.swo
*.db-journal
*.db
migrations