code: def add_user():
      
      load_jws_from_request(request)
      if not hasattr(request, 'jws_header') or request.jws_header is None:
          return "Invalid Payload", 401
      username = request.jws_payload['data'].get('username')
      address = request.jws_header['kid']
      last_nonce = request.jws_payload['iat']*1000
      try:
          user, userkey = create_user_and_key(username=username, address=address, last_nonce=last_nonce, session=ses)
      except IOError:
          ses.rollback()
          ses.flush()
          return 'username or key taken', 400
      jresult = json.loads(jsonify2(userkey, 'UserKey'))
      current_app.logger.info("registered user %s with key %s" % (user.id, userkey.key))
      ses.close()
      return current_app.bitjws.create_response(jresult)
docs: Register a new User.
      Create a User and a UserKey based on the JWS header and payload.
      ---
      operationId:
        addUser
      parameters:
        - name: user
          in: body
          description: A new User to add
          required: true
          schema:
            $ref: '#/definitions/User'
      responses:
        '200':
          description: "user's new key"
          schema:
            $ref: '#/definitions/UserKey'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/errorModel'
      security:
        - kid: []
        - typ: []
        - alg: []