Improve login handling using hooks

Conflicts:
	client/helpers.coffee