Implemented unlocking on login

This was delayed due to an auth_session hash and got waylayed. Now
lock/unlock check will happen on login so you can't lock yourself out of
a patient