Made sure the user can’t navigate to another page when they shouldn’t via the URL
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
import {User} from "@/interfaces/user";
|
||||
import moment from "moment";
|
||||
|
||||
export const preventNavigation = (navDisabled: boolean, focusMode: boolean): boolean => {
|
||||
if (navDisabled) return true;
|
||||
if (focusMode) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
export const shouldRedirectHome = (user: User) => {
|
||||
if (user.isDisabled) return true;
|
||||
if (user.isFirstLogin) return true;
|
||||
if (!user.demographicInformation) return true;
|
||||
if (user.subscriptionExpirationDate && moment(new Date()).isAfter(user.subscriptionExpirationDate)) return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user