1
1
/* tslint:disable:no-console*/
2
2
import { LeaderboardActions , SubmissionActions } from 'app/actions' ;
3
3
import * as LeaderboardFetch from 'app/apiFetch/Leaderboard' ;
4
+ import { checkAuthentication } from 'app/sagas/utils' ;
4
5
import { Request } from 'app/types/code/Submission' ;
5
6
import { resType } from 'app/types/sagas' ;
6
7
import { all , call , put , takeEvery } from 'redux-saga/effects' ;
@@ -13,6 +14,8 @@ export function* getLeaderboard(action: ActionType<typeof LeaderboardActions.get
13
14
pageNo : action . payload . pageNo ,
14
15
pageSize : action . payload . pageSize ,
15
16
} ) ;
17
+ const isAuthenticated = yield checkAuthentication ( result ) ;
18
+ if ( isAuthenticated === false ) return ;
16
19
yield put ( LeaderboardActions . updateError ( result . error ) ) ;
17
20
if ( result . type !== resType . ERROR ) {
18
21
yield put (
@@ -36,6 +39,8 @@ export function* getLeaderboardByDiv(
36
39
pageNo : action . payload . pageNo ,
37
40
pageSize : action . payload . pageSize ,
38
41
} ) ;
42
+ const isAuthenticated = yield checkAuthentication ( result ) ;
43
+ if ( isAuthenticated === false ) return ;
39
44
yield put ( LeaderboardActions . updateError ( result . error ) ) ;
40
45
if ( result . type !== resType . ERROR ) {
41
46
yield put (
@@ -59,6 +64,8 @@ export function* getLeaderboardByUserType(
59
64
pageNo : action . payload . pageNo ,
60
65
pageSize : action . payload . pageSize ,
61
66
} ) ;
67
+ const isAuthenticated = yield checkAuthentication ( result ) ;
68
+ if ( isAuthenticated === false ) return ;
62
69
yield put ( LeaderboardActions . updateError ( result . error ) ) ;
63
70
if ( result . type !== resType . ERROR ) {
64
71
yield put (
@@ -83,6 +90,8 @@ export function* getLeaderboardLeaderboardByDivAndType(
83
90
pageNo : action . payload . pageNo ,
84
91
pageSize : action . payload . pageSize ,
85
92
} ) ;
93
+ const isAuthenticated = yield checkAuthentication ( result ) ;
94
+ if ( isAuthenticated === false ) return ;
86
95
yield put ( LeaderboardActions . updateError ( result . error ) ) ;
87
96
if ( result . type !== resType . ERROR ) {
88
97
yield put (
@@ -107,6 +116,8 @@ export function* getLeaderboardSearch(
107
116
pageSize : action . payload . pageSize ,
108
117
username : action . payload . username ,
109
118
} ) ;
119
+ const isAuthenticated = yield checkAuthentication ( result ) ;
120
+ if ( isAuthenticated === false ) return ;
110
121
yield put ( LeaderboardActions . updateError ( result . okay ) ) ;
111
122
112
123
if ( result . type !== resType . ERROR ) {
@@ -124,7 +135,9 @@ export function* getLeaderboardSearch(
124
135
export function * getTimerSaga ( ) {
125
136
try {
126
137
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 ) ;
128
141
yield put ( LeaderboardActions . setTimer ( time ) ) ;
129
142
} catch ( err ) {
130
143
console . error ( err ) ;
0 commit comments