User registration

Added user registion to the api route /api/register. Also fixed a few
error in using a valid json token again in login, register, or logout.

Logging in again with a valid json token just returns that same token.
Logging out with a valid token will log you out.
Registering with a valid token will just return the same token.

The code needs to be cleaned up and external validation added.