{authDetails.message}
@@ -50,6 +57,7 @@ const SimpleAuth = ({ insecureLogin, history, authDetails }) => {
name="email"
required
type="email"
+ data-test={LOGIN_EMAIL_ID}
/>
@@ -58,8 +66,8 @@ const SimpleAuth = ({ insecureLogin, history, authDetails }) => {
type="submit"
variant="contained"
color="primary"
- data-test="login-submit"
className={styles.button}
+ data-test={LOGIN_BUTTON}
>
Sign in
@@ -71,8 +79,6 @@ const SimpleAuth = ({ insecureLogin, history, authDetails }) => {
SimpleAuth.propTypes = {
authDetails: PropTypes.object.isRequired,
- insecureLogin: PropTypes.func.isRequired,
- history: PropTypes.object.isRequired,
};
export default SimpleAuth;
diff --git a/frontend/src/component/user/SimpleAuth/index.jsx b/frontend/src/component/user/SimpleAuth/index.jsx
deleted file mode 100644
index 5d169efa90..0000000000
--- a/frontend/src/component/user/SimpleAuth/index.jsx
+++ /dev/null
@@ -1,3 +0,0 @@
-import SimpleAuth from './SimpleAuth';
-
-export default SimpleAuth;
diff --git a/frontend/src/component/user/UserProfile/index.tsx b/frontend/src/component/user/UserProfile/index.tsx
index 3ece468a26..5868eccd02 100644
--- a/frontend/src/component/user/UserProfile/index.tsx
+++ b/frontend/src/component/user/UserProfile/index.tsx
@@ -1,16 +1,20 @@
-import useUser from '../../../hooks/api/getters/useUser/useUser';
import UserProfile from './UserProfile';
import { useLocationSettings } from '../../../hooks/useLocationSettings';
+import { useAuthUser } from '../../../hooks/api/getters/useAuth/useAuthUser';
const UserProfileContainer = () => {
- const user = useUser();
const { locationSettings, setLocationSettings } = useLocationSettings();
+ const { user } = useAuthUser();
+
+ if (!user) {
+ return null;
+ }
return (
);
};
diff --git a/frontend/src/component/user/common/AuthOptions/AuthOptions.tsx b/frontend/src/component/user/common/AuthOptions/AuthOptions.tsx
index 6787685c20..e6008c644b 100644
--- a/frontend/src/component/user/common/AuthOptions/AuthOptions.tsx
+++ b/frontend/src/component/user/common/AuthOptions/AuthOptions.tsx
@@ -1,10 +1,11 @@
import { Button } from '@material-ui/core';
import classnames from 'classnames';
import { useCommonStyles } from '../../../../common.styles';
-import { IAuthOptions } from '../../../../interfaces/user';
import { ReactComponent as GoogleSvg } from '../../../../assets/icons/google.svg';
import LockRounded from '@material-ui/icons/LockRounded';
import ConditionallyRender from '../../../common/ConditionallyRender';
+import { IAuthOptions } from '../../../../hooks/api/getters/useAuth/useAuthEndpoint';
+import { SSO_LOGIN_BUTTON } from '../../../../testIds';
interface IAuthOptionProps {
options?: IAuthOptions[];
@@ -28,6 +29,7 @@ const AuthOptions = ({ options }: IAuthOptionProps) => {
variant="outlined"
href={o.path}
size="small"
+ data-test={`${SSO_LOGIN_BUTTON}-${o.type}`}
style={{ height: '40px', color: '#000' }}
startIcon={
boolean;
+}
+
+const hasAccessPlaceholder = () => {
+ throw new Error('hasAccess called outside AccessContext');
+};
+
+const AccessContext = React.createContext({
+ isAdmin: false,
+ hasAccess: hasAccessPlaceholder,
+});
+
+export default AccessContext;
diff --git a/frontend/src/hooks/api/actions/useAdminUsersApi/useAdminUsersApi.ts b/frontend/src/hooks/api/actions/useAdminUsersApi/useAdminUsersApi.ts
index 5fa6f9cde1..379d017bcb 100644
--- a/frontend/src/hooks/api/actions/useAdminUsersApi/useAdminUsersApi.ts
+++ b/frontend/src/hooks/api/actions/useAdminUsersApi/useAdminUsersApi.ts
@@ -1,5 +1,3 @@
-import { IUserPayload } from '../../../../interfaces/user';
-
import useAPI from '../useApi/useApi';
import {
handleBadRequest,
@@ -16,6 +14,12 @@ export interface IUserApiErrors {
validatePassword?: string;
}
+interface IUserPayload {
+ name: string;
+ email: string;
+ id?: string;
+}
+
export const ADD_USER_ERROR = 'addUser';
export const UPDATE_USER_ERROR = 'updateUser';
export const REMOVE_USER_ERROR = 'removeUser';
diff --git a/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx b/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx
new file mode 100644
index 0000000000..9e5e2bb907
--- /dev/null
+++ b/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx
@@ -0,0 +1,51 @@
+import useAPI from '../useApi/useApi';
+
+type PasswordLogin = (
+ path: string,
+ username: string,
+ password: string
+) => Promise;
+
+type EmailLogin = (path: string, email: string) => Promise;
+
+interface IUseAuthApiOutput {
+ passwordAuth: PasswordLogin;
+ emailAuth: EmailLogin;
+ errors: Record;
+ loading: boolean;
+}
+
+export const useAuthApi = (): IUseAuthApiOutput => {
+ const { makeRequest, createRequest, errors, loading } = useAPI({
+ propagateErrors: true,
+ });
+
+ const passwordAuth = (path: string, username: string, password: string) => {
+ const req = createRequest(ensureRelativePath(path), {
+ method: 'POST',
+ body: JSON.stringify({ username, password }),
+ });
+
+ return makeRequest(req.caller, req.id);
+ };
+
+ const emailAuth = (path: string, email: string) => {
+ const req = createRequest(ensureRelativePath(path), {
+ method: 'POST',
+ body: JSON.stringify({ email }),
+ });
+
+ return makeRequest(req.caller, req.id);
+ };
+
+ return {
+ passwordAuth,
+ emailAuth,
+ errors,
+ loading,
+ };
+};
+
+const ensureRelativePath = (path: string): string => {
+ return path.replace(/^\//, '');
+};
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthDetails.ts b/frontend/src/hooks/api/getters/useAuth/useAuthDetails.ts
new file mode 100644
index 0000000000..33dbc02707
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthDetails.ts
@@ -0,0 +1,24 @@
+import {
+ IAuthEndpointDetailsResponse,
+ useAuthEndpoint,
+} from './useAuthEndpoint';
+
+interface IUseAuthDetailsOutput {
+ authDetails?: IAuthEndpointDetailsResponse;
+ refetchAuthDetails: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+export const useAuthDetails = (): IUseAuthDetailsOutput => {
+ const auth = useAuthEndpoint();
+ const authDetails =
+ auth.data && 'type' in auth.data ? auth.data : undefined;
+
+ return {
+ authDetails,
+ refetchAuthDetails: auth.refetchAuth,
+ loading: auth.loading,
+ error: auth.error,
+ };
+};
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthEndpoint.ts b/frontend/src/hooks/api/getters/useAuth/useAuthEndpoint.ts
new file mode 100644
index 0000000000..37eeb86932
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthEndpoint.ts
@@ -0,0 +1,84 @@
+import useSWR, { mutate } from 'swr';
+import { useCallback } from 'react';
+import { formatApiPath } from '../../../../utils/format-path';
+import { IPermission, IUser } from '../../../../interfaces/user';
+
+// The auth endpoint returns different things depending on the auth status.
+// When the user is logged in, the endpoint returns user data and permissions.
+// When the user is logged out, the endpoint returns details on how to log in.
+type AuthEndpointResponse =
+ | IAuthEndpointUserResponse
+ | IAuthEndpointDetailsResponse;
+
+export interface IAuthEndpointUserResponse {
+ user: IUser;
+ feedback: IAuthFeedback[];
+ permissions: IPermission[];
+ splash: IAuthSplash;
+}
+
+export interface IAuthEndpointDetailsResponse {
+ type: string;
+ path: string;
+ message: string;
+ defaultHidden: boolean;
+ options: IAuthOptions[];
+}
+
+export interface IAuthOptions {
+ type: string;
+ message: string;
+ path: string;
+}
+
+export interface IAuthFeedback {
+ neverShow: boolean;
+ feedbackId: string;
+ given?: string;
+ userId: number;
+}
+
+export interface IAuthSplash {
+ [key: string]: boolean;
+}
+
+interface IUseAuthEndpointOutput {
+ data?: AuthEndpointResponse;
+ refetchAuth: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+// This helper hook returns the raw response data from the user auth endpoint.
+// Check out the other hooks in this directory for more ergonomic alternatives.
+export const useAuthEndpoint = (): IUseAuthEndpointOutput => {
+ const { data, error } = useSWR(
+ USER_ENDPOINT_PATH,
+ fetchAuthStatus,
+ swrConfig
+ );
+
+ const refetchAuth = useCallback(() => {
+ mutate(USER_ENDPOINT_PATH).catch(console.warn);
+ }, []);
+
+ return {
+ data,
+ refetchAuth,
+ loading: !error && !data,
+ error,
+ };
+};
+
+const fetchAuthStatus = (): Promise => {
+ return fetch(USER_ENDPOINT_PATH).then(res => res.json());
+};
+
+const swrConfig = {
+ revalidateIfStale: false,
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ refreshInterval: 15000,
+};
+
+export const USER_ENDPOINT_PATH = formatApiPath(`api/admin/user`);
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthFeedback.ts b/frontend/src/hooks/api/getters/useAuth/useAuthFeedback.ts
new file mode 100644
index 0000000000..3f9d6bda89
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthFeedback.ts
@@ -0,0 +1,21 @@
+import { IAuthFeedback, useAuthEndpoint } from './useAuthEndpoint';
+
+interface IUseAuthFeedbackOutput {
+ feedback?: IAuthFeedback[];
+ refetchFeedback: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+export const useAuthFeedback = (): IUseAuthFeedbackOutput => {
+ const auth = useAuthEndpoint();
+ const feedback =
+ auth.data && 'feedback' in auth.data ? auth.data.feedback : undefined;
+
+ return {
+ feedback,
+ refetchFeedback: auth.refetchAuth,
+ loading: auth.loading,
+ error: auth.error,
+ };
+};
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthPermissions.ts b/frontend/src/hooks/api/getters/useAuth/useAuthPermissions.ts
new file mode 100644
index 0000000000..3cb4d2fd2e
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthPermissions.ts
@@ -0,0 +1,24 @@
+import { IPermission } from '../../../../interfaces/user';
+import { useAuthEndpoint } from './useAuthEndpoint';
+
+interface IUseAuthPermissionsOutput {
+ permissions?: IPermission[];
+ refetchPermissions: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+export const useAuthPermissions = (): IUseAuthPermissionsOutput => {
+ const auth = useAuthEndpoint();
+ const permissions =
+ auth.data && 'permissions' in auth.data
+ ? auth.data.permissions
+ : undefined;
+
+ return {
+ permissions,
+ refetchPermissions: auth.refetchAuth,
+ loading: auth.loading,
+ error: auth.error,
+ };
+};
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthSplash.ts b/frontend/src/hooks/api/getters/useAuth/useAuthSplash.ts
new file mode 100644
index 0000000000..38956e7875
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthSplash.ts
@@ -0,0 +1,21 @@
+import { IAuthSplash, useAuthEndpoint } from './useAuthEndpoint';
+
+interface IUseAuthSplashOutput {
+ splash?: IAuthSplash;
+ refetchSplash: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+export const useAuthSplash = (): IUseAuthSplashOutput => {
+ const auth = useAuthEndpoint();
+ const splash =
+ auth.data && 'splash' in auth.data ? auth.data.splash : undefined;
+
+ return {
+ splash,
+ refetchSplash: auth.refetchAuth,
+ loading: auth.loading,
+ error: auth.error,
+ };
+};
diff --git a/frontend/src/hooks/api/getters/useAuth/useAuthUser.ts b/frontend/src/hooks/api/getters/useAuth/useAuthUser.ts
new file mode 100644
index 0000000000..2a142a55e1
--- /dev/null
+++ b/frontend/src/hooks/api/getters/useAuth/useAuthUser.ts
@@ -0,0 +1,21 @@
+import { IUser } from '../../../../interfaces/user';
+import { useAuthEndpoint } from './useAuthEndpoint';
+
+interface IUseAuthUserOutput {
+ user?: IUser;
+ refetchUser: () => void;
+ loading: boolean;
+ error?: Error;
+}
+
+export const useAuthUser = (): IUseAuthUserOutput => {
+ const auth = useAuthEndpoint();
+ const user = auth.data && 'user' in auth.data ? auth.data.user : undefined;
+
+ return {
+ user,
+ refetchUser: auth.refetchAuth,
+ loading: auth.loading,
+ error: auth.error,
+ };
+};
diff --git a/frontend/src/hooks/api/getters/useUser/useUser.ts b/frontend/src/hooks/api/getters/useUser/useUser.ts
deleted file mode 100644
index 6297eeec48..0000000000
--- a/frontend/src/hooks/api/getters/useUser/useUser.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import useSWR, { mutate, SWRConfiguration } from 'swr';
-import { useState, useEffect } from 'react';
-import { formatApiPath } from '../../../../utils/format-path';
-import { IPermission } from '../../../../interfaces/user';
-import handleErrorResponses from '../httpErrorResponseHandler';
-
-export const USER_CACHE_KEY = `api/admin/user`;
-const NO_AUTH_USERNAME = 'unknown';
-
-const useUser = (
- options: SWRConfiguration = {
- revalidateIfStale: false,
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- refreshInterval: 15000,
- }
-) => {
- const fetcher = () => {
- const path = formatApiPath(`api/admin/user`);
- return fetch(path, {
- method: 'GET',
- })
- .then(handleErrorResponses('User info'))
- .then(res => res.json());
- };
-
- const { data, error } = useSWR(USER_CACHE_KEY, fetcher, options);
- const [loading, setLoading] = useState(!error && !data);
-
- const refetch = () => {
- mutate(USER_CACHE_KEY);
- };
-
- useEffect(() => {
- setLoading(!error && !data);
- }, [data, error]);
-
- let user = data?.user;
- // Set a user id if no authentication is on
- // to cancel the loader.
-
- if (data && user?.username === NO_AUTH_USERNAME) {
- user = { ...user, id: 1 };
- }
-
- return {
- user: user || {},
- permissions: (data?.permissions || []) as IPermission[],
- feedback: data?.feedback || [],
- splash: data?.splash || {},
- authDetails: data || undefined,
- error,
- loading,
- refetch,
- };
-};
-
-export default useUser;
diff --git a/frontend/src/hooks/usePermissions.ts b/frontend/src/hooks/usePermissions.ts
deleted file mode 100644
index e9fbe80fc2..0000000000
--- a/frontend/src/hooks/usePermissions.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { useContext } from 'react';
-import AccessContext from '../contexts/AccessContext';
-
-const usePermissions = () => {
- return useContext(AccessContext);
-};
-
-export default usePermissions;
diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx
index 028bac1bcb..02ae50648c 100644
--- a/frontend/src/index.tsx
+++ b/frontend/src/index.tsx
@@ -43,7 +43,7 @@ ReactDOM.render(
-
+
diff --git a/frontend/src/interfaces/user.ts b/frontend/src/interfaces/user.ts
index ae48d444e1..3c19e970bd 100644
--- a/frontend/src/interfaces/user.ts
+++ b/frontend/src/interfaces/user.ts
@@ -1,34 +1,3 @@
-export interface IAuthStatus {
- authDetails: IAuthDetails;
- showDialog: boolean;
- profile?: IUser;
- permissions: IPermission[];
- splash: ISplash;
-}
-
-export interface ISplash {
- [key: string]: boolean;
-}
-
-export interface IPermission {
- permission: string;
- project: string;
- displayName: string;
-}
-
-interface IAuthDetails {
- type: string;
- path: string;
- message: string;
- options: IAuthOptions[];
-}
-
-export interface IAuthOptions {
- type: string;
- message: string;
- path: string;
-}
-
export interface IUser {
id: number;
email: string;
@@ -43,14 +12,8 @@ export interface IUser {
username?: string;
}
-export interface IUserPayload {
- name: string;
- email: string;
- id?: string;
+export interface IPermission {
+ permission: string;
+ project?: string;
+ environment?: string;
}
-
-export interface IAddedUser extends IUser {
- emailSent?: boolean;
-}
-
-export default IAuthStatus;
diff --git a/frontend/src/store/application/index.js b/frontend/src/store/application/index.js
index 06da890586..a5f57e2afa 100644
--- a/frontend/src/store/application/index.js
+++ b/frontend/src/store/application/index.js
@@ -1,6 +1,5 @@
import { fromJS, List, Map } from 'immutable';
import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION, UPDATE_APPLICATION_FIELD, DELETE_APPLICATION } from './actions';
-import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
function getInitState() {
return fromJS({ list: [], apps: {} });
@@ -19,9 +18,6 @@ const store = (state = getInitState(), action) => {
const result = state.removeIn(['list', index]);
return result.removeIn(['apps', action.appName]);
}
- case USER_LOGOUT:
- case USER_LOGIN:
- return getInitState();
default:
return state;
}
diff --git a/frontend/src/store/feature-toggle/index.js b/frontend/src/store/feature-toggle/index.js
index d7a305a5b3..2ae1dbb69a 100644
--- a/frontend/src/store/feature-toggle/index.js
+++ b/frontend/src/store/feature-toggle/index.js
@@ -9,8 +9,6 @@ import {
TOGGLE_FEATURE_TOGGLE,
} from './actions';
-import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
-
const debug = require('debug')('unleash:feature-store');
const features = (state = new List([]), action) => {
@@ -62,10 +60,6 @@ const features = (state = new List([]), action) => {
case RECEIVE_FEATURE_TOGGLES:
debug(RECEIVE_FEATURE_TOGGLES, action);
return new List(action.featureToggles.map($Map));
- case USER_LOGIN:
- case USER_LOGOUT:
- debug(USER_LOGOUT, action);
- return new List([]);
default:
return state;
}
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
index 13aea0e75a..d1496447ad 100644
--- a/frontend/src/store/index.js
+++ b/frontend/src/store/index.js
@@ -2,7 +2,6 @@ import { combineReducers } from 'redux';
import features from './feature-toggle';
import strategies from './strategy';
import error from './error';
-import user from './user';
import applications from './application';
import projects from './project';
import apiCalls from './api-calls';
@@ -11,7 +10,6 @@ const unleashStore = combineReducers({
features,
strategies,
error,
- user,
applications,
projects,
apiCalls,
diff --git a/frontend/src/store/project/index.js b/frontend/src/store/project/index.js
index c191f76cd5..abf6a82d6d 100644
--- a/frontend/src/store/project/index.js
+++ b/frontend/src/store/project/index.js
@@ -1,6 +1,5 @@
import { List } from 'immutable';
import { RECEIVE_PROJECT, REMOVE_PROJECT, ADD_PROJECT, UPDATE_PROJECT } from './actions';
-import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
const DEFAULT_PROJECTS = [{ id: 'default', name: 'Default', initial: true }];
@@ -22,9 +21,6 @@ const strategies = (state = getInitState(), action) => {
const index = state.findIndex(item => item.id === action.project.id);
return state.set(index, action.project);
}
- case USER_LOGOUT:
- case USER_LOGIN:
- return getInitState();
default:
return state;
}
diff --git a/frontend/src/store/user/actions.js b/frontend/src/store/user/actions.js
deleted file mode 100644
index c9687dc8c9..0000000000
--- a/frontend/src/store/user/actions.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import api from './api';
-import { dispatchError } from '../util';
-export const USER_CHANGE_CURRENT = 'USER_CHANGE_CURRENT';
-export const USER_LOGOUT = 'USER_LOGOUT';
-export const USER_LOGIN = 'USER_LOGIN';
-export const START_FETCH_USER = 'START_FETCH_USER';
-export const ERROR_FETCH_USER = 'ERROR_FETCH_USER';
-const debug = require('debug')('unleash:user-actions');
-
-const updateUser = value => ({
- type: USER_CHANGE_CURRENT,
- value,
-});
-
-function handleError(error) {
- debug(error);
-}
-
-export function fetchUser() {
- debug('Start fetching user');
- return dispatch => {
- dispatch({ type: START_FETCH_USER });
-
- return api
- .fetchUser()
- .then(json => dispatch(updateUser(json)))
- .catch(dispatchError(dispatch, ERROR_FETCH_USER));
- };
-}
-
-export function insecureLogin(path, user) {
- return dispatch => {
- dispatch({ type: START_FETCH_USER });
-
- return api
- .insecureLogin(path, user)
- .then(json => dispatch(updateUser(json)))
- .catch(handleError);
- };
-}
-
-export function demoLogin(path, user) {
- return dispatch => {
- dispatch({ type: START_FETCH_USER });
-
- return api
- .demoLogin(path, user)
- .then(json => dispatch(updateUser(json)))
- .catch(handleError);
- };
-}
-
-export function passwordLogin(path, user) {
- return dispatch => {
- dispatch({ type: START_FETCH_USER });
-
- return api
- .passwordLogin(path, user)
- .then(json => dispatch(updateUser(json)))
- .then(() => dispatch({ type: USER_LOGIN }));
- };
-}
diff --git a/frontend/src/store/user/api.js b/frontend/src/store/user/api.js
deleted file mode 100644
index 1e54c701ee..0000000000
--- a/frontend/src/store/user/api.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import { formatApiPath } from '../../utils/format-path';
-import { throwIfNotSuccess, headers } from '../api-helper';
-
-const URI = formatApiPath('api/admin/user');
-
-function fetchUser() {
- return fetch(URI, { credentials: 'include' })
- .then(throwIfNotSuccess)
- .then(response => response.json());
-}
-
-function insecureLogin(path, user) {
- return fetch(path, {
- method: 'POST',
- credentials: 'include',
- headers,
- body: JSON.stringify(user),
- })
- .then(throwIfNotSuccess)
- .then(response => response.json());
-}
-
-function demoLogin(path, user) {
- return fetch(path, {
- method: 'POST',
- credentials: 'include',
- headers,
- body: JSON.stringify(user),
- })
- .then(throwIfNotSuccess)
- .then(response => response.json());
-}
-
-function passwordLogin(path, data) {
- return fetch(path, {
- method: 'POST',
- credentials: 'include',
- headers,
- body: JSON.stringify(data),
- })
- .then(throwIfNotSuccess)
- .then(response => response.json());
-}
-
-const api = {
- fetchUser,
- insecureLogin,
- demoLogin,
- passwordLogin,
-};
-
-export default api;
diff --git a/frontend/src/store/user/index.js b/frontend/src/store/user/index.js
deleted file mode 100644
index 957cb93e99..0000000000
--- a/frontend/src/store/user/index.js
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Map as $Map } from 'immutable';
-import { USER_CHANGE_CURRENT, USER_LOGOUT } from './actions';
-import { AUTH_REQUIRED } from '../util';
-
-const userStore = (state = new $Map({ permissions: [] }), action) => {
- switch (action.type) {
- case USER_CHANGE_CURRENT:
- state = state
- .set('profile', action.value.user)
- .set('permissions', action.value.permissions || [])
- .set('feedback', action.value.feedback || [])
- .set('splash', action.value.splash || {})
- .set('showDialog', false)
- .set('authDetails', undefined);
- return state;
- case AUTH_REQUIRED:
- state = state
- .set('authDetails', action.error.body)
- .set('showDialog', true);
- return state;
- case USER_LOGOUT:
- return new $Map({ permissions: [] });
- default:
- return state;
- }
-};
-
-export default userStore;
diff --git a/frontend/src/testIds.js b/frontend/src/testIds.js
index ba6984e647..e72fb77e77 100644
--- a/frontend/src/testIds.js
+++ b/frontend/src/testIds.js
@@ -15,6 +15,8 @@ export const CF_CREATE_BTN_ID = 'CF_CREATE_BTN_ID';
export const LOGIN_EMAIL_ID = 'LOGIN_EMAIL_ID';
export const LOGIN_BUTTON = 'LOGIN_BUTTON';
export const LOGIN_PASSWORD_ID = 'LOGIN_PASSWORD_ID';
+export const SSO_LOGIN_BUTTON = 'SSO_LOGIN_BUTTON';
+export const FORGOTTEN_PASSWORD_FIELD = 'FORGOTTEN_PASSWORD_FIELD';
/* STRATEGY */
export const ADD_NEW_STRATEGY_ID = 'ADD_NEW_STRATEGY_ID';
diff --git a/frontend/src/utils/project-filter-generator.ts b/frontend/src/utils/project-filter-generator.ts
index 3e271fd478..88cf2d8e9b 100644
--- a/frontend/src/utils/project-filter-generator.ts
+++ b/frontend/src/utils/project-filter-generator.ts
@@ -1,16 +1,16 @@
import { ADMIN } from '../component/providers/AccessProvider/permissions';
-import IAuthStatus, { IPermission } from '../interfaces/user';
+import { IPermission } from '../interfaces/user';
type objectIdx = {
[key: string]: string;
};
export const projectFilterGenerator = (
- user: IAuthStatus,
+ permissions: IPermission[] = [],
matcherPermission: string
) => {
let admin = false;
- const permissionMap: objectIdx = user.permissions.reduce(
+ const permissionMap: objectIdx = permissions.reduce(
(acc: objectIdx, current: IPermission) => {
if (current.permission === ADMIN) {
admin = true;