11/* tslint:disable:no-console*/
22import { LeaderboardActions , SubmissionActions } from 'app/actions' ;
33import * as LeaderboardFetch from 'app/apiFetch/Leaderboard' ;
4+ import { checkAuthentication } from 'app/sagas/utils' ;
45import { Request } from 'app/types/code/Submission' ;
56import { resType } from 'app/types/sagas' ;
67import { all , call , put , takeEvery } from 'redux-saga/effects' ;
@@ -13,6 +14,8 @@ export function* getLeaderboard(action: ActionType<typeof LeaderboardActions.get
1314 pageNo : action . payload . pageNo ,
1415 pageSize : action . payload . pageSize ,
1516 } ) ;
17+ const isAuthenticated = yield checkAuthentication ( result ) ;
18+ if ( isAuthenticated === false ) return ;
1619 yield put ( LeaderboardActions . updateError ( result . error ) ) ;
1720 if ( result . type !== resType . ERROR ) {
1821 yield put (
@@ -36,6 +39,8 @@ export function* getLeaderboardByDiv(
3639 pageNo : action . payload . pageNo ,
3740 pageSize : action . payload . pageSize ,
3841 } ) ;
42+ const isAuthenticated = yield checkAuthentication ( result ) ;
43+ if ( isAuthenticated === false ) return ;
3944 yield put ( LeaderboardActions . updateError ( result . error ) ) ;
4045 if ( result . type !== resType . ERROR ) {
4146 yield put (
@@ -59,6 +64,8 @@ export function* getLeaderboardByUserType(
5964 pageNo : action . payload . pageNo ,
6065 pageSize : action . payload . pageSize ,
6166 } ) ;
67+ const isAuthenticated = yield checkAuthentication ( result ) ;
68+ if ( isAuthenticated === false ) return ;
6269 yield put ( LeaderboardActions . updateError ( result . error ) ) ;
6370 if ( result . type !== resType . ERROR ) {
6471 yield put (
@@ -83,6 +90,8 @@ export function* getLeaderboardLeaderboardByDivAndType(
8390 pageNo : action . payload . pageNo ,
8491 pageSize : action . payload . pageSize ,
8592 } ) ;
93+ const isAuthenticated = yield checkAuthentication ( result ) ;
94+ if ( isAuthenticated === false ) return ;
8695 yield put ( LeaderboardActions . updateError ( result . error ) ) ;
8796 if ( result . type !== resType . ERROR ) {
8897 yield put (
@@ -107,6 +116,8 @@ export function* getLeaderboardSearch(
107116 pageSize : action . payload . pageSize ,
108117 username : action . payload . username ,
109118 } ) ;
119+ const isAuthenticated = yield checkAuthentication ( result ) ;
120+ if ( isAuthenticated === false ) return ;
110121 yield put ( LeaderboardActions . updateError ( result . okay ) ) ;
111122
112123 if ( result . type !== resType . ERROR ) {
@@ -124,7 +135,9 @@ export function* getLeaderboardSearch(
124135export function * getTimerSaga ( ) {
125136 try {
126137 const result = yield call ( LeaderboardFetch . getTimer ) ;
127- const time = Number ( result ) ;
138+ const isAuthenticated = yield checkAuthentication ( result ) ;
139+ if ( isAuthenticated === false ) return ;
140+ const time = Number ( result . body ) ;
128141 yield put ( LeaderboardActions . setTimer ( time ) ) ;
129142 } catch ( err ) {
130143 console . error ( err ) ;
0 commit comments