Skip to content

Commit ea357d3

Browse files
committed
Add admin to auth object
1 parent 47388e4 commit ea357d3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

client/actions/auth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const loginUser = payload => async dispatch => {
4646
const { data: { token } } = await axios.post('/api/auth/login', payload);
4747
cookie.set('token', token, { expires: 7 });
4848
dispatch(authRenew());
49-
dispatch(authUser(decodeJwt(token).sub));
49+
dispatch(authUser(decodeJwt(token)));
5050
dispatch(setDomain(decodeJwt(token).domain));
5151
dispatch(showPageLoading());
5252
Router.push('/');
@@ -77,7 +77,7 @@ export const renewAuthUser = () => async (dispatch, getState) => {
7777
const { data: { token } } = await axios(options);
7878
cookie.set('token', token, { expires: 7 });
7979
dispatch(authRenew());
80-
dispatch(authUser(decodeJwt(token).sub));
80+
dispatch(authUser(decodeJwt(token)));
8181
dispatch(setDomain(decodeJwt(token).domain));
8282
} catch (error) {
8383
cookie.remove('token');

client/reducers/auth.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { AUTH_USER, AUTH_RENEW, UNAUTH_USER, SENT_VERIFICATION } from '../actions/actionTypes';
22

33
const initialState = {
4+
admin: false,
45
isAuthenticated: false,
56
sentVerification: false,
67
user: '',
@@ -13,7 +14,8 @@ const auth = (state = initialState, action) => {
1314
return {
1415
...state,
1516
isAuthenticated: true,
16-
user: action.payload,
17+
user: action.payload.sub,
18+
admin: action.payload.admin,
1719
sentVerification: false,
1820
};
1921
case AUTH_RENEW:

0 commit comments

Comments
 (0)