mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-09 22:00:20 +01:00
use logout link of index resource
This commit is contained in:
@@ -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<Props> {
|
||||
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))
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
})
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user