Skip to content

Commit 5366428

Browse files
author
Sascha Pfeiffer
committed
Merge branch 'develop' into 'master'
Preparing v1.7.14 See merge request psono/psono-admin-client!72
2 parents c8bb7e4 + e4a3195 commit 5366428

File tree

5 files changed

+103
-12
lines changed

5 files changed

+103
-12
lines changed

public/locales/en/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"DELETE_OIDC_GROUP_CONFIRM_DIALOG": "You are about to delete OIDC groups. Are you sure?",
9494
"DELETE_SAML_GROUP_CONFIRM_DIALOG": "You are about to delete SAML groups. Are you sure?",
9595
"DELETE_SCIM_GROUP_CONFIRM_DIALOG": "You are about to delete SCIM groups. Are you sure?",
96+
"WIPE_USER_CONFIRM_DIALOG": "You are about to wipe users. The users will be resetted and all their data will be lost. Are you sure?",
9697
"DELETE_USER_CONFIRM_DIALOG": "You are about to delete users. Are you sure?",
9798
"DELETE_GROUP_CONFIRM_DIALOG": "You are about to delete groups. Are you sure?",
9899
"ABORT": "Abort",
@@ -233,6 +234,7 @@
233234
"MEMBERS": "Members",
234235
"MANAGED": "Managed",
235236
"EMAIL_ACTIVE": "E-Mail active",
237+
"WIPE_USER_S": "Wipe user(s)",
236238
"DELETE_USER_S": "Delete user(s)",
237239
"DELETE_LDAP_GROUP_S": "Delete LDAP group(s)",
238240
"DELETE_OIDC_GROUP_S": "Delete OIDC group(s)",

src/containers/Index/Index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,24 @@ const App = (props) => {
5959
const { classes, ...rest } = props;
6060

6161
let variableLinks = [];
62-
if (props.state.server.type === 'EE') {
62+
if (store.getState().server.type === 'EE') {
6363
eeLinks.forEach((link) => variableLinks.push(link));
6464
}
6565
if (
66-
props.state.server.type === 'EE' &&
67-
props.state.server.authentication_methods.includes('LDAP')
66+
store.getState().server.type === 'EE' &&
67+
store.getState().server.authentication_methods.includes('LDAP')
6868
) {
6969
ldapLinks.forEach((link) => variableLinks.push(link));
7070
}
7171
if (
72-
props.state.server.type === 'EE' &&
73-
props.state.server.authentication_methods.includes('SAML')
72+
store.getState().server.type === 'EE' &&
73+
store.getState().server.authentication_methods.includes('SAML')
7474
) {
7575
samlLinks.forEach((link) => variableLinks.push(link));
7676
}
7777
if (
78-
props.state.server.type === 'EE' &&
79-
props.state.server.authentication_methods.includes('OIDC')
78+
store.getState().server.type === 'EE' &&
79+
store.getState().server.authentication_methods.includes('OIDC')
8080
) {
8181
oidcLinks.forEach((link) => variableLinks.push(link));
8282
}

src/services/api-server.js

+24
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,29 @@ function admin_delete_user(token, session_secret_key, user_id) {
10461046
return call(method, endpoint, data, headers, session_secret_key);
10471047
}
10481048

1049+
/**
1050+
* POST: Wipes a user (for administrators)
1051+
*
1052+
* @param {string} token authentication token of the user, returned by authentication_login(email, authkey)
1053+
* @param {string} session_secret_key The session secret key
1054+
* @param {uuid} user_id The user id of the user to delete
1055+
*
1056+
* @returns {Promise<AxiosResponse<any>>}
1057+
*/
1058+
function admin_wipe_user(token, session_secret_key, user_id) {
1059+
const endpoint = '/admin/user-wipe/';
1060+
const method = 'POST';
1061+
const data = {
1062+
user_id: user_id,
1063+
};
1064+
const headers = {
1065+
'Content-Type': 'application/json',
1066+
Authorization: 'Token ' + token,
1067+
};
1068+
1069+
return call(method, endpoint, data, headers, session_secret_key);
1070+
}
1071+
10491072
/**
10501073
* DELETE: Deletes a session (for administrators)
10511074
*
@@ -3643,6 +3666,7 @@ const service = {
36433666
admin_security_report,
36443667
admin_create_user,
36453668
admin_delete_user,
3669+
admin_wipe_user,
36463670
admin_delete_session,
36473671
admin_policy,
36483672
admin_policy_create_group_map,

src/views/Group/Create.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const GroupCreate = (props) => {
2626
const [autoCreateFolder, setAutoCreateFolder] = useState(false);
2727

2828
React.useEffect(() => {
29-
const is_ee_server = props.state.server.type === 'EE';
29+
const is_ee_server = store.getState().server.type === 'EE';
3030

3131
if (!is_ee_server) {
3232
setRedirectTo('/dashboard');

src/views/User/Edit.jsx

+69-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import { useParams } from 'react-router-dom';
3+
import { useHistory, useParams } from 'react-router-dom';
44
import moment from 'moment';
55

66
import { makeStyles } from '@material-ui/core/styles';
@@ -18,15 +18,19 @@ import {
1818
import psono_server from '../../services/api-server';
1919
import customInputStyle from '../../assets/jss/material-dashboard-react/customInputStyle';
2020
import store from '../../services/store';
21+
import DeleteConfirmDialog from '../../components/Dialog/DeleteConfirmDialog';
2122

2223
const useStyles = makeStyles(customInputStyle);
2324
const UserEdit = () => {
2425
const classes = useStyles();
2526
const { t } = useTranslation();
27+
const history = useHistory();
2628
const { user_id } = useParams();
2729
const [user, setUser] = useState(null);
2830
const [errors, setErrors] = useState([]);
2931
const [msgs, setMsgs] = useState([]);
32+
const [deleteUserModalOpen, setDeleteUserModalOpen] = useState(false);
33+
const [wipeUserModalOpen, setWipeUserModalOpen] = useState(false);
3034

3135
React.useEffect(() => {
3236
loadUser();
@@ -448,6 +452,50 @@ const UserEdit = () => {
448452

449453
return (
450454
<div>
455+
{deleteUserModalOpen && (
456+
<DeleteConfirmDialog
457+
title={t('DELETE_USER_S')}
458+
onConfirm={() => {
459+
psono_server
460+
.admin_delete_user(
461+
store.getState().user.token,
462+
store.getState().user.session_secret_key,
463+
user.id
464+
)
465+
.then(() => {
466+
history.push('/user/');
467+
});
468+
setDeleteUserModalOpen(false);
469+
}}
470+
onAbort={() => {
471+
setDeleteUserModalOpen(false);
472+
}}
473+
>
474+
{t('DELETE_USER_CONFIRM_DIALOG')}
475+
</DeleteConfirmDialog>
476+
)}
477+
{wipeUserModalOpen && (
478+
<DeleteConfirmDialog
479+
title={t('WIPE_USER_S')}
480+
onConfirm={() => {
481+
psono_server
482+
.admin_wipe_user(
483+
store.getState().user.token,
484+
store.getState().user.session_secret_key,
485+
user.id
486+
)
487+
.then(() => {
488+
history.push('/user/');
489+
});
490+
setWipeUserModalOpen(false);
491+
}}
492+
onAbort={() => {
493+
setWipeUserModalOpen(false);
494+
}}
495+
>
496+
{t('WIPE_USER_CONFIRM_DIALOG')}
497+
</DeleteConfirmDialog>
498+
)}
451499
<Grid container>
452500
<GridItem xs={12} sm={12} md={12}>
453501
<RegularCard
@@ -599,9 +647,26 @@ const UserEdit = () => {
599647
</div>
600648
}
601649
footer={
602-
<Button color="primary" onClick={save}>
603-
{t('SAVE')}
604-
</Button>
650+
<>
651+
<Button color="primary" onClick={save}>
652+
{t('SAVE')}
653+
</Button>
654+
<Button
655+
onClick={() => setDeleteUserModalOpen(true)}
656+
>
657+
{t('DELETE')}
658+
</Button>
659+
{store.getState().server.type == 'EE' &&
660+
user.authentication !== 'AUTHKEY' && (
661+
<Button
662+
onClick={() =>
663+
setWipeUserModalOpen(true)
664+
}
665+
>
666+
{t('WIPE')}
667+
</Button>
668+
)}
669+
</>
605670
}
606671
/>
607672
</GridItem>

0 commit comments

Comments
 (0)