Set user in localStorage when matching auth token is found. When checking guest access, consider if a username is set. Fixes username local storage exploits.

This commit is contained in:
kristian
2022-09-10 21:33:45 -07:00
parent ef59eb25f4
commit 5a3fbe5672
4 changed files with 17 additions and 14 deletions

View File

@@ -5,15 +5,14 @@
*/
// Import helper functions from auth, to get current user, and check if guest
import { getCurrentUser, isLoggedInAsGuest } from '@/utils/Auth';
import { getCurrentUser } from '@/utils/Auth';
import { isVisibleToUser } from '@/utils/IsVisibleToUser';
/* Putting it all together, the function to export */
export const checkItemVisibility = (item) => {
const currentUser = getCurrentUser(); // Get current user object
const isGuest = isLoggedInAsGuest(); // Check if current user is a guest
const displayData = item.displayData || {};
return isVisibleToUser(displayData, currentUser, isGuest);
return isVisibleToUser(displayData, currentUser);
};
export default checkItemVisibility;