Make sign-in/out idempotent; Fixes #630, #631

This is a little WET but whatevs.