diff --git a/src/constants/index.js b/src/constants/index.js
index fa899de3..b17473bd 100644
--- a/src/constants/index.js
+++ b/src/constants/index.js
@@ -201,6 +201,11 @@ export const ACTION_TYPE = {
AUTH_LOAD_TEAM_MEMBERS_ERROR: "AUTH_LOAD_TEAM_MEMBERS_ERROR",
AUTH_CLEAR_TEAM_MEMBERS: "AUTH_CLEAR_TEAM_MEMBERS",
+ AUTH_LOAD_V5_USER_PROFILE: "AUTH_LOAD_V5_USER_PROFILE",
+ AUTH_LOAD_V5_USER_PROFILE_PENDING: "AUTH_LOAD_V5_USER_PROFILE_PENDING",
+ AUTH_LOAD_V5_USER_PROFILE_SUCCESS: "AUTH_LOAD_V5_USER_PROFILE_SUCCESS",
+ AUTH_LOAD_V5_USER_PROFILE_ERROR: "AUTH_LOAD_V5_USER_PROFILE_ERROR",
+
/*
Email Popup
*/
diff --git a/src/hoc/withAuthentication/actions/index.js b/src/hoc/withAuthentication/actions/index.js
index 904e2c25..8a466a95 100644
--- a/src/hoc/withAuthentication/actions/index.js
+++ b/src/hoc/withAuthentication/actions/index.js
@@ -2,7 +2,7 @@
* Auth User actions
*/
import { ACTION_TYPE } from "constants";
-import { getTeamMembers } from "services/teams";
+import { getTeamMembers, getV5UserProfile } from "services/teams";
/**
* Action to set auth user data
@@ -40,6 +40,19 @@ export const authLoadTeamMembers = (teamId) => ({
},
});
+/**
+ * Loads v5 user profile for authentication/permission purposes
+ *
+ * @returns {Promise} loaded user profile
+ */
+export const authLoadV5UserProfile = () => ({
+ type: ACTION_TYPE.AUTH_LOAD_V5_USER_PROFILE,
+ payload: async () => {
+ const res = await getV5UserProfile();
+ return res.data;
+ },
+});
+
/**
* Clear team members for authentication/permission purposes
*
diff --git a/src/hoc/withAuthentication/index.js b/src/hoc/withAuthentication/index.js
index a3d76bed..d8670662 100644
--- a/src/hoc/withAuthentication/index.js
+++ b/src/hoc/withAuthentication/index.js
@@ -19,6 +19,7 @@ import {
authUserSuccess,
authUserError,
authLoadTeamMembers,
+ authLoadV5UserProfile,
authClearTeamMembers,
} from "./actions";
import { decodeToken } from "tc-auth-lib";
@@ -34,6 +35,9 @@ export default function withAuthentication(Component) {
teamId,
teamMembersLoaded,
teamMembersLoadingError,
+ v5UserProfile,
+ v5UserProfileLoading,
+ v5UserProfileLoadingError,
} = useSelector((state) => state.authUser);
const params = useParams();
@@ -86,18 +90,27 @@ export default function withAuthentication(Component) {
}
}, [params.teamId, teamId, dispatch, isLoggedIn]);
+ useEffect(() => {
+ if (isLoggedIn) {
+ dispatch(authLoadV5UserProfile());
+ }
+ }, [dispatch, isLoggedIn]);
+
return (
<>
{/* Show loading indicator until we know if user is logged-in or no.
Also, show loading indicator if we need to know team members but haven't loaded them yet.
+ or load v5 user profile but haven't loaded them yet.
In we got error during this process, show error */}
{isLoggedIn === null ||
- (params.teamId && !teamMembersLoaded && (
-