Expand permissions/role system. Clients are now provisioned with their roles when they join and will have features enabled/disabled based on their permissions.

This commit is contained in:
Håvar Aambø Fosstveit
2020-04-02 00:28:05 +02:00
parent 197156e6f6
commit a6347dc283
16 changed files with 211 additions and 135 deletions
+1 -3
View File
@@ -1,11 +1,9 @@
import * as userRoles from './userRoles';
const initialState =
{
id : null,
picture : null,
isMobile : false,
roles : [ userRoles.ALL ],
roles : [ 'normal' ], // Default role
canSendMic : false,
canSendWebcam : false,
canShareScreen : false,
+24 -1
View File
@@ -21,7 +21,16 @@ const initialState =
joined : false,
muteAllInProgress : false,
stopAllVideoInProgress : false,
closeMeetingInProgress : false
closeMeetingInProgress : false,
userRoles : { NORMAL: 'normal' }, // Default role
permissionsFromRoles : {
CHANGE_ROOM_LOCK : [],
PROMOTE_PEER : [],
SEND_CHAT : [],
SHARE_SCREEN : [],
SHARE_FILE : [],
MODERATE_ROOM : []
}
};
const room = (state = initialState, action) =>
@@ -175,6 +184,20 @@ const room = (state = initialState, action) =>
case 'CLOSE_MEETING_IN_PROGRESS':
return { ...state, closeMeetingInProgress: action.payload.flag };
case 'SET_USER_ROLES':
{
const { userRoles } = action.payload;
return { ...state, userRoles };
}
case 'SET_PERMISSIONS_FROM_ROLES':
{
const { permissionsFromRoles } = action.payload;
return { ...state, permissionsFromRoles };
}
default:
return state;
}
-4
View File
@@ -1,4 +0,0 @@
export const ADMIN = 'admin';
export const MODERATOR = 'moderator';
export const AUTHENTICATED = 'authenticated';
export const ALL = 'normal';