fix review findings

This commit is contained in:
Eduard Heimbuch
2020-08-11 10:34:29 +02:00
parent a46d8c4749
commit c1cfff603b
63 changed files with 578 additions and 494 deletions

View File

@@ -118,7 +118,7 @@ describe("auth actions", () => {
fetchMock.postOnce("/api/v2/auth/access_token", {
body: {
cookie: true,
grantType: "password",
grant_type: "password",
username: "tricia",
password: "secret123"
},

View File

@@ -32,7 +32,8 @@ import {
callFetchIndexResources,
fetchIndexResources,
fetchIndexResourcesPending,
fetchIndexResourcesSuccess, getLoginLink
fetchIndexResourcesSuccess,
getLoginLink
} from "./indexResource";
import { AnyAction } from "redux";
@@ -176,7 +177,7 @@ const callFetchMe = (link: string): Promise<Me> => {
export const login = (loginLink: string, username: string, password: string) => {
const loginData = {
cookie: true,
grantType: "password",
grant_type: "password",
username,
password
};
@@ -219,7 +220,7 @@ export const fetchMe = (link: string) => {
};
};
export const logout = (link: string) => {
export const logout = (link: string, callback: () => void) => {
return function(dispatch: any) {
dispatch(logoutPending());
return apiClient
@@ -247,6 +248,7 @@ export const logout = (link: string) => {
dispatch(fetchIndexResources());
}
})
.then(callback)
.catch(error => {
dispatch(logoutFailure(error));
});