mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
apply prettier, removed flow related config and added tsconfig
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
import { Me } from '@scm-manager/ui-types';
|
||||
import * as types from './types';
|
||||
import { Me } from "@scm-manager/ui-types";
|
||||
import * as types from "./types";
|
||||
|
||||
import { apiClient, UnauthorizedError } from '@scm-manager/ui-components';
|
||||
import { isPending } from './pending';
|
||||
import { getFailure } from './failure';
|
||||
import { apiClient, UnauthorizedError } from "@scm-manager/ui-components";
|
||||
import { isPending } from "./pending";
|
||||
import { getFailure } from "./failure";
|
||||
import {
|
||||
callFetchIndexResources,
|
||||
fetchIndexResources,
|
||||
fetchIndexResourcesPending,
|
||||
fetchIndexResourcesSuccess,
|
||||
getLoginLink,
|
||||
} from './indexResource';
|
||||
getLoginLink
|
||||
} from "./indexResource";
|
||||
|
||||
// Action
|
||||
|
||||
export const LOGIN = 'scm/auth/LOGIN';
|
||||
export const LOGIN = "scm/auth/LOGIN";
|
||||
export const LOGIN_PENDING = `${LOGIN}_${types.PENDING_SUFFIX}`;
|
||||
export const LOGIN_SUCCESS = `${LOGIN}_${types.SUCCESS_SUFFIX}`;
|
||||
export const LOGIN_FAILURE = `${LOGIN}_${types.FAILURE_SUFFIX}`;
|
||||
|
||||
export const FETCH_ME = 'scm/auth/FETCH_ME';
|
||||
export const FETCH_ME = "scm/auth/FETCH_ME";
|
||||
export const FETCH_ME_PENDING = `${FETCH_ME}_${types.PENDING_SUFFIX}`;
|
||||
export const FETCH_ME_SUCCESS = `${FETCH_ME}_${types.SUCCESS_SUFFIX}`;
|
||||
export const FETCH_ME_FAILURE = `${FETCH_ME}_${types.FAILURE_SUFFIX}`;
|
||||
export const FETCH_ME_UNAUTHORIZED = `${FETCH_ME}_UNAUTHORIZED`;
|
||||
|
||||
export const LOGOUT = 'scm/auth/LOGOUT';
|
||||
export const LOGOUT = "scm/auth/LOGOUT";
|
||||
export const LOGOUT_PENDING = `${LOGOUT}_${types.PENDING_SUFFIX}`;
|
||||
export const LOGOUT_SUCCESS = `${LOGOUT}_${types.SUCCESS_SUFFIX}`;
|
||||
export const LOGOUT_FAILURE = `${LOGOUT}_${types.FAILURE_SUFFIX}`;
|
||||
@@ -38,19 +38,19 @@ const initialState = {};
|
||||
export default function reducer(
|
||||
state: object = initialState,
|
||||
action: object = {
|
||||
type: 'UNKNOWN',
|
||||
},
|
||||
type: "UNKNOWN"
|
||||
}
|
||||
) {
|
||||
switch (action.type) {
|
||||
case LOGIN_SUCCESS:
|
||||
case FETCH_ME_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
me: action.payload,
|
||||
me: action.payload
|
||||
};
|
||||
case FETCH_ME_UNAUTHORIZED:
|
||||
return {
|
||||
me: {},
|
||||
me: {}
|
||||
};
|
||||
case LOGOUT_SUCCESS:
|
||||
return initialState;
|
||||
@@ -59,7 +59,7 @@ export default function reducer(
|
||||
// we keep the current state until we are redirected to the new page
|
||||
return {
|
||||
...state,
|
||||
redirecting: true,
|
||||
redirecting: true
|
||||
};
|
||||
}
|
||||
default:
|
||||
@@ -71,73 +71,73 @@ export default function reducer(
|
||||
|
||||
export const loginPending = () => {
|
||||
return {
|
||||
type: LOGIN_PENDING,
|
||||
type: LOGIN_PENDING
|
||||
};
|
||||
};
|
||||
|
||||
export const loginSuccess = (me: Me) => {
|
||||
return {
|
||||
type: LOGIN_SUCCESS,
|
||||
payload: me,
|
||||
payload: me
|
||||
};
|
||||
};
|
||||
|
||||
export const loginFailure = (error: Error) => {
|
||||
return {
|
||||
type: LOGIN_FAILURE,
|
||||
payload: error,
|
||||
payload: error
|
||||
};
|
||||
};
|
||||
|
||||
export const logoutPending = () => {
|
||||
return {
|
||||
type: LOGOUT_PENDING,
|
||||
type: LOGOUT_PENDING
|
||||
};
|
||||
};
|
||||
|
||||
export const logoutSuccess = () => {
|
||||
return {
|
||||
type: LOGOUT_SUCCESS,
|
||||
type: LOGOUT_SUCCESS
|
||||
};
|
||||
};
|
||||
|
||||
export const redirectAfterLogout = () => {
|
||||
return {
|
||||
type: LOGOUT_REDIRECT,
|
||||
type: LOGOUT_REDIRECT
|
||||
};
|
||||
};
|
||||
|
||||
export const logoutFailure = (error: Error) => {
|
||||
return {
|
||||
type: LOGOUT_FAILURE,
|
||||
payload: error,
|
||||
payload: error
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchMePending = () => {
|
||||
return {
|
||||
type: FETCH_ME_PENDING,
|
||||
type: FETCH_ME_PENDING
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchMeSuccess = (me: Me) => {
|
||||
return {
|
||||
type: FETCH_ME_SUCCESS,
|
||||
payload: me,
|
||||
payload: me
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchMeUnauthenticated = () => {
|
||||
return {
|
||||
type: FETCH_ME_UNAUTHORIZED,
|
||||
resetPending: true,
|
||||
resetPending: true
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchMeFailure = (error: Error) => {
|
||||
return {
|
||||
type: FETCH_ME_FAILURE,
|
||||
payload: error,
|
||||
payload: error
|
||||
};
|
||||
};
|
||||
|
||||
@@ -152,13 +152,13 @@ const callFetchMe = (link: string): Promise<Me> => {
|
||||
export const login = (
|
||||
loginLink: string,
|
||||
username: string,
|
||||
password: string,
|
||||
password: string
|
||||
) => {
|
||||
const login_data = {
|
||||
cookie: true,
|
||||
grant_type: 'password',
|
||||
grant_type: "password",
|
||||
username,
|
||||
password,
|
||||
password
|
||||
};
|
||||
return function(dispatch: any) {
|
||||
dispatch(loginPending());
|
||||
|
||||
Reference in New Issue
Block a user