Remember identity on response.

        Implements ``morepath.App.remember_identity``, which is called
        from user login code.

        Create a JWT token and return it as the Authorization field of the
        response header.

        :param response: response object on which to store identity.
        :type response: :class:`morepath.Response`
        :param request: request object.
        :type request: :class:`morepath.Request`
        :param identity: identity to remember.
        :type identity: :class:`morepath.Identity`

def remember(self, response, request, identity):
        """Remember identity on response.

        Implements ``morepath.App.remember_identity``, which is called
        from user login code.

        Create a JWT token and return it as the Authorization field of the
        response header.

        :param response: response object on which to store identity.
        :type response: :class:`morepath.Response`
        :param request: request object.
        :type request: :class:`morepath.Request`
        :param identity: identity to remember.
        :type identity: :class:`morepath.Identity`
        """
        claims = identity.as_dict()
        userid = claims.pop('userid')
        claims_set = self.create_claims_set(request, userid, claims)
        token = self.encode_jwt(claims_set)
        response.headers['Authorization'] = '%s %s' % (self.auth_header_prefix,
                                                       token)