Skip to content

Commit

Permalink
Get user and place their data in the Redux store after login
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl committed Sep 25, 2024
1 parent c6406b4 commit 5972336
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/volto/src/components/theme/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { toast } from 'react-toastify';
import { Toast } from '@plone/volto/components';
import aheadSVG from '@plone/volto/icons/ahead.svg';
import clearSVG from '@plone/volto/icons/clear.svg';
import { useUser } from '@plone/volto/hooks';

const messages = defineMessages({
login: {
Expand Down Expand Up @@ -85,6 +86,9 @@ const Login = (props) => {

const previousToken = usePrevious(token);

// Get user and place their data in the Redux store
useUser();

useEffect(() => {
if (location?.state?.isLogout) {
// Execute a true Logout action
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/hooks/user/useUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const useFetchUser = () => {
const dispatch = useDispatch();

useEffect(() => {
if (!user?.id) {
if (!user?.id && userId) {
dispatch(getUser(userId));
}
}, [dispatch, userId, user]);
Expand Down

0 comments on commit 5972336

Please sign in to comment.