The Dead Loop of unbinding Social accounts in spring social

read some online tutorials (tutorial address: https://juejin.im/post/5a7ae6.), spring social provides a ConnectController to bind and unbind

where the / connect/ {providerId} (DELETE request) sent by the front end can unbind the relevant binding

then says that such a view of connect/ {providerId} Connect will be returned after the request is called, but this view needs to be extended to implement

.

but I wrote it myself and found that I can indeed delete bindings in the database, but I will not jump to connect/ {providerId} Connect, but keep on looping. Finally, the front end returns ERR_TOO_MANY_REDIRECTS, to view the source code of ConnectController

    @RequestMapping(value="/{providerId}", method=RequestMethod.DELETE)
    public RedirectView removeConnections(@PathVariable String providerId, NativeWebRequest request) {
        ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(providerId);
        preDisconnect(connectionFactory, request);
        connectionRepository.removeConnections(providerId);
        postDisconnect(connectionFactory, request);
        return connectionStatusRedirect(providerId, request);
    }

    protected RedirectView connectionStatusRedirect(String providerId, NativeWebRequest request) {
        HttpServletRequest servletRequest = request.getNativeRequest(HttpServletRequest.class);
        String path = "/connect/" + providerId + getPathExtension(servletRequest);
        if (prependServletPath(servletRequest)) {
            path = servletRequest.getServletPath() + path;
        }
        return new RedirectView(path, true);
    }

    private String getPathExtension(HttpServletRequest request) {
        String fileName = WebUtils.extractFullFilenameFromUrlPath(request.getRequestURI());        
        String extension = StringUtils.getFilenameExtension(fileName);
        return extension != null ? "." + extension : "";
    }

the above source code does not convert / connect/ {providerId} into connect/ {providerId} Connect. Won"t the final return connectionStatusRedirect (providerId, request) go back to removeConnections?

Aug.17,2021

you can't send an ajax request because it has been tested by yourself. You can just submit it in the form of form

.
<form action="/connect/github" method="POST">
    <input id="method" type="hidden" name="_method" value="delete"/>
    <button></button>
</form>
Menu