mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
fix provider login
This commit is contained in:
@ -10,6 +10,7 @@ import { useLocalState } from '../states/LocalState';
|
|||||||
import { useUserState } from '../states/UserState';
|
import { useUserState } from '../states/UserState';
|
||||||
import { type Provider, fetchGlobalStates } from '../states/states';
|
import { type Provider, fetchGlobalStates } from '../states/states';
|
||||||
import { showLoginNotification } from './notifications';
|
import { showLoginNotification } from './notifications';
|
||||||
|
import { generateUrl } from './urls';
|
||||||
|
|
||||||
export function followRedirect(navigate: NavigateFunction, redirect: any) {
|
export function followRedirect(navigate: NavigateFunction, redirect: any) {
|
||||||
let url = redirect?.redirectUrl ?? '/home';
|
let url = redirect?.redirectUrl ?? '/home';
|
||||||
@ -287,21 +288,17 @@ export function clearCsrfCookie() {
|
|||||||
'csrftoken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
'csrftoken=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ProviderLogin(
|
export async function ProviderLogin(
|
||||||
provider: Provider,
|
provider: Provider,
|
||||||
process: 'login' | 'connect' = 'login'
|
process: 'login' | 'connect' = 'login'
|
||||||
) {
|
) {
|
||||||
const { host } = useLocalState.getState();
|
await ensureCsrf();
|
||||||
// TODO
|
post(generateUrl(apiUrl(ApiEndpoints.auth_provider_redirect)), {
|
||||||
const loc = window.location;
|
|
||||||
const values = {
|
|
||||||
provider: provider.id,
|
provider: provider.id,
|
||||||
callback_url: 'http://localhost:8000/logged-in',
|
callback_url: generateUrl('/logged-in'),
|
||||||
process: process,
|
process: process,
|
||||||
csrfmiddlewaretoken: getCsrfCookie()
|
csrfmiddlewaretoken: getCsrfCookie()
|
||||||
};
|
});
|
||||||
const url = `${host}${apiUrl(ApiEndpoints.auth_provider_redirect)}`;
|
|
||||||
post(url, values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user