diff --git a/scm-ui/src/containers/Logout.js b/scm-ui/src/containers/Logout.js index 8d522a18bf..fe6662da42 100644 --- a/scm-ui/src/containers/Logout.js +++ b/scm-ui/src/containers/Logout.js @@ -11,14 +11,16 @@ import { getLogoutFailure } from "../modules/auth"; import { Loading, ErrorPage } from "@scm-manager/ui-components"; +import { getLogoutLink } from "../modules/indexResource"; type Props = { authenticated: boolean, loading: boolean, error: Error, + logoutLink: string, // dispatcher functions - logout: () => void, + logout: (link: string) => void, // context props t: string => string @@ -26,7 +28,7 @@ type Props = { class Logout extends React.Component { componentDidMount() { - this.props.logout(); + this.props.logout(this.props.logoutLink); } render() { @@ -51,16 +53,18 @@ const mapStateToProps = state => { const authenticated = isAuthenticated(state); const loading = isLogoutPending(state); const error = getLogoutFailure(state); + const logoutLink = getLogoutLink(state); return { authenticated, loading, - error + error, + logoutLink }; }; const mapDispatchToProps = dispatch => { return { - logout: () => dispatch(logout()) + logout: (link: string) => dispatch(logout(link)) }; }; diff --git a/scm-ui/src/modules/auth.js b/scm-ui/src/modules/auth.js index f150c59d3c..add4d879ce 100644 --- a/scm-ui/src/modules/auth.js +++ b/scm-ui/src/modules/auth.js @@ -180,11 +180,11 @@ export const fetchMe = () => { }; }; -export const logout = () => { +export const logout = (link: string) => { return function(dispatch: any) { dispatch(logoutPending()); return apiClient - .delete(LOGIN_URL) + .delete(link) .then(() => { dispatch(logoutSuccess()); }) diff --git a/scm-ui/src/modules/auth.test.js b/scm-ui/src/modules/auth.test.js index 3cea758566..23f0ffe83b 100644 --- a/scm-ui/src/modules/auth.test.js +++ b/scm-ui/src/modules/auth.test.js @@ -188,7 +188,7 @@ describe("auth actions", () => { const store = mockStore({}); - return store.dispatch(logout()).then(() => { + return store.dispatch(logout("/auth/access_token")).then(() => { expect(store.getActions()).toEqual(expectedActions); }); }); @@ -199,7 +199,7 @@ describe("auth actions", () => { }); const store = mockStore({}); - return store.dispatch(logout()).then(() => { + return store.dispatch(logout("/auth/access_token")).then(() => { const actions = store.getActions(); expect(actions[0].type).toEqual(LOGOUT_PENDING); expect(actions[1].type).toEqual(LOGOUT_FAILURE);