Skip to content

Commit

Permalink
Add redirecting to auth page for not authorized users
Browse files Browse the repository at this point in the history
  • Loading branch information
AshurovG committed Dec 15, 2024
1 parent 107a17e commit beb954a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion public/components/CoWatchBlock/CoWatchBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import template from './CoWatchBlock.hbs';
import { userStore } from 'store/UserStore';
import { Actions } from 'flux/Actions';
import { CreateRoomModal } from 'components/CreateRoomModal/CreateRoomModal';
import { router } from 'modules/Router';
import { Notifier } from 'components/Notifier/Notifier';

export class CoWatchBlock {
#parent: HTMLElement;
Expand Down Expand Up @@ -45,7 +47,17 @@ export class CoWatchBlock {
if (subscribtionButton) {
subscribtionButton.addEventListener('click', (event) => {
event.preventDefault();
Actions.buySubscription({ subscriptionForm, subscriptionFormLabel });
if (userStore.getUser().username) {
Actions.buySubscription({ subscriptionForm, subscriptionFormLabel });
} else {
const notifier = new Notifier(
'error',
'Сначала необходимо войти в аккаунт',
3000,
);
notifier.render();
router.go('/auth');
}
});
}
}
Expand Down

0 comments on commit beb954a

Please sign in to comment.