User roles
This commit is contained in:
parent
7ade45864c
commit
15dec50d94
|
@ -149,6 +149,17 @@ const RocketChat = {
|
|||
}).then(response => response.json());
|
||||
},
|
||||
|
||||
userInfo({ server, token, userId }) {
|
||||
return fetch(`${ server }/api/v1/users.info?userId=${ userId }`, {
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Auth-Token': token,
|
||||
'X-User-Id': userId
|
||||
}
|
||||
}).then(response => response.json());
|
||||
},
|
||||
|
||||
register({ credentials }) {
|
||||
return call('registerUser', credentials);
|
||||
},
|
||||
|
|
|
@ -26,6 +26,7 @@ const setUsernameCall = args => RocketChat.setUsername(args);
|
|||
const logoutCall = args => RocketChat.logout(args);
|
||||
const meCall = args => RocketChat.me(args);
|
||||
const forgotPasswordCall = args => RocketChat.forgotPassword(args);
|
||||
const userInfoCall = args => RocketChat.userInfo(args);
|
||||
|
||||
const getToken = function* getToken() {
|
||||
const currentServer = yield select(getServer);
|
||||
|
@ -76,6 +77,10 @@ const handleLoginRequest = function* handleLoginRequest({ credentials }) {
|
|||
// if user has username
|
||||
if (me.username) {
|
||||
user.username = me.username;
|
||||
const userInfo = yield call(userInfoCall, { server, token: user.token, userId: user.id });
|
||||
if (userInfo.user.roles) {
|
||||
user.roles = userInfo.user.roles;
|
||||
}
|
||||
} else {
|
||||
yield put(registerIncomplete());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue