Skip to content

Commit

Permalink
GH-1070: fixed the disconnect user error on user connect page (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kshitij-Katiyar authored Jul 12, 2024
1 parent e89cdae commit 93e0be7
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion assets/templates/oauth2/complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
margin-right: 4px;
}
</style>
<script>
const handleDisconnect = () => {
// Splitting the cookies string on the basis of cookie name and then popping out the first value.
const token = ('; ' + document.cookie).split('; MMCSRF=').pop().split(';')[0];

fetch("{{ .RevokeURL }}", {
method: "POST",
headers: {'X-CSRF-Token': token},
}).then(res => {
const element = document.body;
if(!res.ok) {
element.style.margin = "10px";
} else {
window.close();
}

return res.text().then(text => element.innerHTML = text);
})
}
</script>
<link rel="stylesheet" href="https://unpkg.com/@atlaskit/[email protected]/dist/bundle.css" media="all">
</head>
<body>
Expand All @@ -71,7 +91,7 @@ <h3>
<div>It is now safe to close this browser window.</div>
</div>
<a href="javascript:window.close();" class="btn btn-link">Close</a>
<a href="{{ .RevokeURL }}" class="btn btn-link">Disconnect</a>
<button onclick="handleDisconnect()" class="btn btn-link">Disconnect</button>
</div>
</body>
</html>

0 comments on commit 93e0be7

Please sign in to comment.