1
1
/**
2
- * @module actions/ auth
3
- * @desc Auth- related actions .
2
+ * @module " actions. auth"
3
+ * @desc Actions related to Topcoder authentication system .
4
4
*/
5
5
6
- import _ from 'lodash' ;
7
6
import { createActions } from 'redux-actions' ;
8
7
import { decodeToken } from 'tc-accounts' ;
9
8
import { getApiV3 } from '../services/api' ;
10
9
11
10
/**
12
- * Loads profile of the authenticated user.
13
- * @alias module:actions/auth
14
- * @param {String } userTokenV3 Topcoder auth token V3.
15
- * @return {Promise }
16
- * @fulfil {Object} User profile object.
11
+ * @static
12
+ * @desc Creates an action that loads Topcoder user profile from v3 API.
13
+ * @param {String } userTokenV3 v3 authentication token.
14
+ * @return {Action }
17
15
*/
18
16
function loadProfileDone ( userTokenV3 ) {
19
17
if ( ! userTokenV3 ) return Promise . resolve ( null ) ;
@@ -30,20 +28,31 @@ function loadProfileDone(userTokenV3) {
30
28
}
31
29
32
30
/**
33
- * @function test
34
- * @desc test
31
+ * @static
32
+ * @desc Creates an action that sets Topcoder v2 authentication token.
33
+ * @param {String } tokenV2 Topcoder v2 authentication token.
34
+ * @return {Action }
35
35
*/
36
+ function setTcTokenV2 ( tokenV2 ) {
37
+ return tokenV2 ;
38
+ }
39
+
40
+ /**
41
+ * @static
42
+ * @desc Creates an action that decodes Topcoder v3 authentication token,
43
+ * to get user object, and then writes both the token and the user object into
44
+ * Redux store.
45
+ * @param {String } tokenV3 Topcoder v3 authentication token.
46
+ * @return {Action }
47
+ */
48
+ function setTcTokenV3 ( tokenV3 ) {
49
+ return tokenV3 ;
50
+ }
36
51
37
52
export default createActions ( {
38
53
AUTH : {
39
54
LOAD_PROFILE : loadProfileDone ,
40
-
41
- /* Given TC auth token V2, this action writes it into state.auth.tokenV2. */
42
- SET_TC_TOKEN_V2 : _ . identity ,
43
-
44
- /* Given TC auth token V3 this action:
45
- * - Decodes token and writes resulting user object into state.auth.user;
46
- * - Writes the token itself into state.auth.tokenV3. */
47
- SET_TC_TOKEN_V3 : _ . identity ,
55
+ SET_TC_TOKEN_V2 : setTcTokenV2 ,
56
+ SET_TC_TOKEN_V3 : setTcTokenV3 ,
48
57
} ,
49
58
} ) ;
0 commit comments