feat(sso): launch modules through one-time grants
This commit is contained in:
@@ -32,13 +32,6 @@ const Dashboard = () => {
|
|||||||
try {
|
try {
|
||||||
const response = await moduleApi.launchModule(moduleId);
|
const response = await moduleApi.launchModule(moduleId);
|
||||||
|
|
||||||
await fetch(response.target_url, {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json", ...response.headers },
|
|
||||||
body: JSON.stringify(response.payload),
|
|
||||||
credentials: "include",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.redirect_url) {
|
if (response.redirect_url) {
|
||||||
try {
|
try {
|
||||||
const url = new URL(response.redirect_url);
|
const url = new URL(response.redirect_url);
|
||||||
@@ -202,4 +195,4 @@ const Dashboard = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard;
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ export interface Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LaunchResponse {
|
export interface LaunchResponse {
|
||||||
target_url: string;
|
grant_code: string;
|
||||||
payload: Record<string, any>;
|
|
||||||
headers: Record<string, string>;
|
|
||||||
redirect_url: string;
|
redirect_url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,4 +21,4 @@ export const moduleApi = {
|
|||||||
|
|
||||||
launchModule: (moduleId: string): Promise<LaunchResponse> =>
|
launchModule: (moduleId: string): Promise<LaunchResponse> =>
|
||||||
apiClient.post<LaunchResponse>("/api/sso/initiate", { module_id: moduleId }, { toast: false }),
|
apiClient.post<LaunchResponse>("/api/sso/initiate", { module_id: moduleId }, { toast: false }),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user