mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
Handle Plugin Center Authentication failures (#1940)
If the plugin center authentication fails, the plugins are fetched without authentication and a warning is displayed on the plugin page. Co-authored-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
@@ -28,6 +28,16 @@ import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import { apiClient } from "./apiclient";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
const appendQueryParam = (link: Link, name: string, value: string) => {
|
||||
let href = link.href;
|
||||
if (href.includes("?")) {
|
||||
href += "&";
|
||||
} else {
|
||||
href += "?";
|
||||
}
|
||||
link.href = href + name + "=" + value;
|
||||
};
|
||||
|
||||
export const usePluginCenterAuthInfo = (): ApiResult<PluginCenterAuthenticationInfo> => {
|
||||
const link = useIndexLink("pluginCenterAuth");
|
||||
const location = useLocation();
|
||||
@@ -42,7 +52,10 @@ export const usePluginCenterAuthInfo = (): ApiResult<PluginCenterAuthenticationI
|
||||
.then(response => response.json())
|
||||
.then((result: PluginCenterAuthenticationInfo) => {
|
||||
if (result._links?.login) {
|
||||
(result._links.login as Link).href += `?source=${location.pathname}`;
|
||||
appendQueryParam(result._links.login as Link, "source", location.pathname);
|
||||
}
|
||||
if (result._links?.reconnect) {
|
||||
appendQueryParam(result._links.reconnect as Link, "source", location.pathname);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user