33 ACCOUNTS_APP_CONNECTOR_URL ,
44 LOAD_USER_SUCCESS ,
55 LOAD_USER_FAILURE ,
6+ LOAD_USER_CREDENTIAL ,
7+ LOAD_USER_CREDENTIAL_FAILURE ,
68 LOAD_ORG_CONFIG_SUCCESS ,
79 LOAD_ORG_CONFIG_FAILURE ,
810 ROLE_ADMINISTRATOR ,
@@ -16,7 +18,7 @@ import {
1618 ROLE_PRESALES , ROLE_PROJECT_MANAGER , ROLE_SOLUTION_ARCHITECT
1719} from '../config/constants'
1820import { getFreshToken , configureConnector , decodeToken } from 'tc-auth-lib'
19- import { getUserProfile } from '../api/users'
21+ import { getUserProfile , getCredential } from '../api/users'
2022import { fetchGroups } from '../api/groups'
2123import { getOrgConfig } from '../api/orgConfig'
2224import { EventTypes } from 'redux-segment'
@@ -26,6 +28,18 @@ configureConnector({
2628 frameId : 'tc-accounts-iframe'
2729} )
2830
31+ export function getUserCredential ( userId ) {
32+ return ( dispatch ) => {
33+ return dispatch ( {
34+ type : LOAD_USER_CREDENTIAL ,
35+ payload : getCredential ( userId )
36+ } ) . catch ( ( err ) => {
37+ console . log ( err )
38+ dispatch ( { type : LOAD_USER_CREDENTIAL_FAILURE } )
39+ } )
40+ }
41+ }
42+
2943export function loadUser ( ) {
3044 return ( ( dispatch , getState ) => {
3145 const state = getState ( )
@@ -125,9 +139,9 @@ export function loadUserSuccess(dispatch, token) {
125139 loadGroups ( dispatch , currentUser . userId )
126140 } )
127141 . catch ( ( err ) => {
128- // if we fail to load user's profile, still dispatch user load success
129- // ideally it shouldn't happen, but if it is, we can render the page
130- // without profile information
142+ // if we fail to load user's profile, still dispatch user load success
143+ // ideally it shouldn't happen, but if it is, we can render the page
144+ // without profile information
131145 console . log ( err )
132146 dispatch ( { type : LOAD_USER_SUCCESS , user : currentUser } )
133147 } )
@@ -161,7 +175,7 @@ function loadGroups(dispatch, userId) {
161175 }
162176 } )
163177 . catch ( ( err ) => {
164- // if we fail to load groups
178+ // if we fail to load groups
165179 console . log ( err )
166180 } )
167181 }
0 commit comments