mirror of
https://gitlab.com/comunic/comunicconsole
synced 2024-11-23 13:59:23 +00:00
Can delete a user account
This commit is contained in:
parent
ba3bb587dc
commit
f7cd54aa29
@ -82,4 +82,15 @@ export class ComunicUsersHelper {
|
|||||||
})
|
})
|
||||||
).url;
|
).url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a user account
|
||||||
|
*/
|
||||||
|
static async DeleteUserAccount(id: number): Promise<string> {
|
||||||
|
return (
|
||||||
|
await serverRequest("users/delete_account", {
|
||||||
|
user_id: id,
|
||||||
|
})
|
||||||
|
).url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
|
import EmailIcon from "@mui/icons-material/Email";
|
||||||
|
import LinkIcon from "@mui/icons-material/Link";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
@ -7,12 +10,12 @@ import {
|
|||||||
TableCell,
|
TableCell,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import EmailIcon from "@mui/icons-material/Email";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
ComunicUser,
|
ComunicUser,
|
||||||
ComunicUsersHelper,
|
ComunicUsersHelper,
|
||||||
} from "../../helpers/ComunicUsersHelper";
|
} from "../../helpers/ComunicUsersHelper";
|
||||||
|
import { CopyToClipboard } from "../../utils/ClipboardUtils";
|
||||||
import { validateEmail } from "../../utils/StringsUtils";
|
import { validateEmail } from "../../utils/StringsUtils";
|
||||||
import { AsyncWidget } from "../widgets/AsyncWidget";
|
import { AsyncWidget } from "../widgets/AsyncWidget";
|
||||||
import { CustomCard } from "../widgets/CustomCard";
|
import { CustomCard } from "../widgets/CustomCard";
|
||||||
@ -24,8 +27,7 @@ import {
|
|||||||
} from "../widgets/DialogsProvider";
|
} from "../widgets/DialogsProvider";
|
||||||
import { PageTitle } from "../widgets/PageTitle";
|
import { PageTitle } from "../widgets/PageTitle";
|
||||||
import { TimestampWidget } from "../widgets/TimestampWidget";
|
import { TimestampWidget } from "../widgets/TimestampWidget";
|
||||||
import LinkIcon from "@mui/icons-material/Link";
|
|
||||||
import { CopyToClipboard } from "../../utils/ClipboardUtils";
|
|
||||||
interface UserProperty {
|
interface UserProperty {
|
||||||
name: string;
|
name: string;
|
||||||
value?: string | number;
|
value?: string | number;
|
||||||
@ -50,6 +52,7 @@ export class ComunicUserRoute extends React.Component<
|
|||||||
|
|
||||||
this.changeEmailAddress = this.changeEmailAddress.bind(this);
|
this.changeEmailAddress = this.changeEmailAddress.bind(this);
|
||||||
this.createPasswordResetLink = this.createPasswordResetLink.bind(this);
|
this.createPasswordResetLink = this.createPasswordResetLink.bind(this);
|
||||||
|
this.deleteAccount = this.deleteAccount.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get user(): ComunicUser {
|
get user(): ComunicUser {
|
||||||
@ -186,6 +189,31 @@ export class ComunicUserRoute extends React.Component<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteAccount() {
|
||||||
|
try {
|
||||||
|
if (
|
||||||
|
!(await matConfirm(
|
||||||
|
"Do you really want to delete the account of " +
|
||||||
|
this.fullName +
|
||||||
|
"?"
|
||||||
|
)) ||
|
||||||
|
!(await matConfirm(
|
||||||
|
"LAST CHANCE TO COME BACK!!!\nDo you really want to delete the account of " +
|
||||||
|
this.fullName +
|
||||||
|
"?"
|
||||||
|
))
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await ComunicUsersHelper.DeleteUserAccount(this.userID);
|
||||||
|
|
||||||
|
snackbar("The account has been successfully deleted!");
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
matAlert("Failed to delete user account!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
const properties = this.userProperties.map((p) => {
|
const properties = this.userProperties.map((p) => {
|
||||||
return (
|
return (
|
||||||
@ -254,7 +282,7 @@ export class ComunicUserRoute extends React.Component<
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="secondary"
|
color="primary"
|
||||||
startIcon={<EmailIcon />}
|
startIcon={<EmailIcon />}
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@ -268,13 +296,25 @@ export class ComunicUserRoute extends React.Component<
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="secondary"
|
color="primary"
|
||||||
startIcon={<LinkIcon />}
|
startIcon={<LinkIcon />}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
onClick={this.createPasswordResetLink}
|
onClick={this.createPasswordResetLink}
|
||||||
>
|
>
|
||||||
Create password reset link
|
Create password reset link
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<div> </div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
color="secondary"
|
||||||
|
startIcon={<DeleteIcon />}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
onClick={this.deleteAccount}
|
||||||
|
>
|
||||||
|
Delete user account
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CustomCard>
|
</CustomCard>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -265,7 +265,7 @@ export class ApplicationDialogsProvider extends React.Component<
|
|||||||
</DialogContentText>
|
</DialogContentText>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={this.rejectConfirm} color="secondary">
|
<Button onClick={this.rejectConfirm} color="primary">
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={this.acceptConfirm} color="secondary">
|
<Button onClick={this.acceptConfirm} color="secondary">
|
||||||
|
Loading…
Reference in New Issue
Block a user