Server-side code for login and registration via REST.