Finished structure for formatting audits and began writing individual formatting for each audit
Этот коммит содержится в:
@@ -14,6 +14,7 @@ export default class AccessHistoryModal extends React.Component {
|
|||||||
this.handleMoreInfo = this.handleMoreInfo.bind(this);
|
this.handleMoreInfo = this.handleMoreInfo.bind(this);
|
||||||
this.onHide = this.onHide.bind(this);
|
this.onHide = this.onHide.bind(this);
|
||||||
this.onShow = this.onShow.bind(this);
|
this.onShow = this.onShow.bind(this);
|
||||||
|
this.formatAuditInfo = this.formatAuditInfo.bind(this);
|
||||||
|
|
||||||
const state = this.getStateFromStoresForAudits();
|
const state = this.getStateFromStoresForAudits();
|
||||||
state.moreInfo = [];
|
state.moreInfo = [];
|
||||||
@@ -52,74 +53,127 @@ export default class AccessHistoryModal extends React.Component {
|
|||||||
newMoreInfo[index] = true;
|
newMoreInfo[index] = true;
|
||||||
this.setState({moreInfo: newMoreInfo});
|
this.setState({moreInfo: newMoreInfo});
|
||||||
}
|
}
|
||||||
render() {
|
formatAuditInfo(currentAudit) {
|
||||||
var accessList = [];
|
const currentActionURL = currentAudit.action.replace(/\/api\/v[1-9]/, '');
|
||||||
|
|
||||||
for (var i = 0; i < this.state.audits.length; i++) {
|
let currentAuditDesc = ' ';
|
||||||
var currentAudit = this.state.audits[i];
|
|
||||||
var currentDate = new Date(currentAudit.create_at);
|
|
||||||
|
|
||||||
if (!currentAudit.session_id && currentAudit.action.search('/users/login') !== -1) {
|
/* Handle audit formatting semi-individually for each type and
|
||||||
currentAudit.session_id = 'N/A (Login attempt)';
|
fall back to a best guess case if none exists
|
||||||
|
|
||||||
|
Supported audits:
|
||||||
|
/channels
|
||||||
|
- Create Channel X
|
||||||
|
- Update Channel X
|
||||||
|
- Update Channel Description X
|
||||||
|
- Delete Channel X
|
||||||
|
- Add User to Channel X
|
||||||
|
- Remove User from Channel X
|
||||||
|
|
||||||
|
/oauth
|
||||||
|
- Register X
|
||||||
|
- Allow Attempt/Success/Failure X
|
||||||
|
|
||||||
|
/team
|
||||||
|
- Revoke All Sessions X (NO CORRESPONDING ADDRESS/FUNCTION)
|
||||||
|
|
||||||
|
- Revoke Session X
|
||||||
|
- Update (users - ?) X
|
||||||
|
- Update Notify (?) X
|
||||||
|
- Login Attempt X
|
||||||
|
- Login (success/failure) X
|
||||||
|
- Logout (/logout) X
|
||||||
|
- Verify Email (/verify_email) X
|
||||||
|
*/
|
||||||
|
switch (currentActionURL) {
|
||||||
|
|
||||||
|
/* BREAK UP CHANNEL INTO OWN SWITCH STATEMENT TO REUSE VARIABLES AND BE CLEAN */
|
||||||
|
case '/channels/create':
|
||||||
|
const createChannelInfo = currentAudit.extra_info.split('=');
|
||||||
|
let channelName = '';
|
||||||
|
|
||||||
|
if (createChannelInfo[0] === 'name') {
|
||||||
|
channelName = createChannelInfo[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentActionURL = currentAudit.action.replace(/\/api\/v[1-9]/, '');
|
currentAuditDesc = 'Created a new channel/group named ' + channelName;
|
||||||
|
|
||||||
let currentAuditDesc = '';
|
break;
|
||||||
|
case '/channels/update':
|
||||||
|
const updateChannelInfo = currentAudit.extra_info.split('=');
|
||||||
|
let originalChannelName = '';
|
||||||
|
|
||||||
/* Handle specific audit type formatting semi-individually and
|
if (updateChannelInfo[0] === 'name') {
|
||||||
fall back to a best guess case if none exists
|
originalChannelName = updateChannelInfo[1];
|
||||||
|
}
|
||||||
|
|
||||||
Supported audits:
|
currentAuditDesc = 'Updated the channel/group name for ' + originalChannelName;
|
||||||
/channels
|
break;
|
||||||
- Create Channel X
|
|
||||||
- Update Channel X
|
|
||||||
- Update Channel Description X
|
|
||||||
- Delete Channel X
|
|
||||||
- Add User to Channel X
|
|
||||||
- Remove User from Channel X
|
|
||||||
|
|
||||||
/oauth
|
/* case '/channels/update_desc':
|
||||||
- Register X
|
const updateChannelInfo = currentAudit.extra_info.split('=');
|
||||||
- Allow Attempt/Success/Failure X
|
let originalChannelName = '';
|
||||||
|
|
||||||
/team
|
if (updateChannelInfo[0] === 'name') {
|
||||||
- Revoke All Sessions X (NO CORRESPONDING ADDRESS)
|
originalChannelName = updateChannelInfo[1];
|
||||||
|
}
|
||||||
|
|
||||||
- Update (users - ?) X
|
currentAuditDesc = 'Updated the channel/group name for ' + originalChannelName;
|
||||||
- Update Notify (?) X
|
break;*/
|
||||||
- Login Attempt X
|
case /\/channels\/[A-Za-z0-9]+\/delete/:
|
||||||
- Login (success/failure) X
|
break;
|
||||||
- Logout (/logout) X
|
case /\/channels\/[A-Za-z0-9]+\/add/:
|
||||||
*/
|
break;
|
||||||
switch (currentActionURL) {
|
case /\/channels\/[A-Za-z0-9]+\/remove/:
|
||||||
case '/channels/create':
|
break;
|
||||||
break;
|
case '/oauth/register':
|
||||||
case '/channels/update':
|
break;
|
||||||
break;
|
case '/oauth/allow':
|
||||||
case '/channels/update_desc':
|
break;
|
||||||
break;
|
case '/users/login':
|
||||||
case /\/channels\/[A-Za-z0-9]+\/delete/:
|
break;
|
||||||
break;
|
case '/users/revoke_session':
|
||||||
case /\/channels\/[A-Za-z0-9]+\/add/:
|
break;
|
||||||
break;
|
case '/users/newimage':
|
||||||
case /\/channels\/[A-Za-z0-9]+\/remove/:
|
break;
|
||||||
break;
|
case '/users/update':
|
||||||
case '/oauth/register':
|
break;
|
||||||
break;
|
case '/users/newpassword':
|
||||||
case '/oauth/allow':
|
break;
|
||||||
break;
|
case '/users/update_roles':
|
||||||
case '/team/':
|
break;
|
||||||
break;
|
case '/users/update_active':
|
||||||
default:
|
break;
|
||||||
let currentActionDesc = '';
|
case '/users/send_password_reset':
|
||||||
|
break;
|
||||||
|
case '/users/reset_password':
|
||||||
|
break;
|
||||||
|
case '/users/update_notify':
|
||||||
|
break;
|
||||||
|
case '/logout':
|
||||||
|
break;
|
||||||
|
case '/hooks/incoming/create':
|
||||||
|
break;
|
||||||
|
case '/hooks/incoming/delete':
|
||||||
|
break;
|
||||||
|
case '/verify_email':
|
||||||
|
break;
|
||||||
|
case '/oauth/access_token':
|
||||||
|
break;
|
||||||
|
case '':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (currentAudit.extra_info.indexOf('revoked_all=') >= 0) {
|
||||||
|
|
||||||
|
// do stuff
|
||||||
|
} else {
|
||||||
|
let currentActionDesc = ' ';
|
||||||
if (currentActionURL && currentActionURL.lastIndexOf('/') !== -1) {
|
if (currentActionURL && currentActionURL.lastIndexOf('/') !== -1) {
|
||||||
currentActionDesc = currentActionURL.substring(currentActionURL.lastIndexOf('/') + 1).replace('_', ' ');
|
currentActionDesc = currentActionURL.substring(currentActionURL.lastIndexOf('/') + 1).replace('_', ' ');
|
||||||
currentActionDesc = Utils.toTitleCase(currentActionDesc);
|
currentActionDesc = Utils.toTitleCase(currentActionDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentExtraInfoDesc = '';
|
let currentExtraInfoDesc = ' ';
|
||||||
if (currentAudit.extra_info) {
|
if (currentAudit.extra_info) {
|
||||||
currentExtraInfoDesc = currentAudit.extra_info;
|
currentExtraInfoDesc = currentAudit.extra_info;
|
||||||
|
|
||||||
@@ -127,11 +181,23 @@ export default class AccessHistoryModal extends React.Component {
|
|||||||
currentExtraInfoDesc = currentExtraInfoDesc.substring(currentExtraInfoDesc.indexOf('=') + 1);
|
currentExtraInfoDesc = currentExtraInfoDesc.substring(currentExtraInfoDesc.indexOf('=') + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAuditDesc = currentActionDesc + ' ' + currentExtraInfoDesc;
|
currentAuditDesc = currentActionDesc + ' ' + currentExtraInfoDesc;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentDate = new Date(currentAudit.create_at);
|
||||||
|
const currentAuditInfo = currentDate.toDateString() + ' - ' + currentDate.toLocaleTimeString(navigator.language, {hour: '2-digit', minute: '2-digit'}) + ' | ' + currentAuditDesc;
|
||||||
|
return currentAuditInfo;
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
var accessList = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < this.state.audits.length; i++) {
|
||||||
|
const currentAudit = this.state.audits[i];
|
||||||
|
const currentAuditInfo = this.formatAuditInfo(currentAudit);
|
||||||
|
|
||||||
var moreInfo = (
|
var moreInfo = (
|
||||||
<a
|
<a
|
||||||
href='#'
|
href='#'
|
||||||
@@ -143,8 +209,13 @@ export default class AccessHistoryModal extends React.Component {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (this.state.moreInfo[i]) {
|
if (this.state.moreInfo[i]) {
|
||||||
|
if (!currentAudit.session_id && currentAudit.action.search('/users/login') !== -1) {
|
||||||
|
currentAudit.session_id = 'N/A (Login attempt)';
|
||||||
|
}
|
||||||
|
|
||||||
moreInfo = (
|
moreInfo = (
|
||||||
<div>
|
<div>
|
||||||
|
<div>{'IP: ' + currentAudit.ip_address}</div>
|
||||||
<div>{'Session ID: ' + currentAudit.session_id}</div>
|
<div>{'Session ID: ' + currentAudit.session_id}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -161,7 +232,7 @@ export default class AccessHistoryModal extends React.Component {
|
|||||||
className='access-history__table'
|
className='access-history__table'
|
||||||
>
|
>
|
||||||
<div className='access__report'>
|
<div className='access__report'>
|
||||||
<div className='report__time'>{currentDate.toDateString() + ' - ' + currentDate.toLocaleTimeString(navigator.language, {hour: '2-digit', minute: '2-digit'}) + ' | ' + currentAuditDesc + ' from ' + currentAudit.ip_address}</div>
|
<div className='report__time'>{currentAuditInfo}</div>
|
||||||
<div className='report__info'>
|
<div className='report__info'>
|
||||||
{moreInfo}
|
{moreInfo}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user