mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-25 02:36:20 +01:00
Allow user to change admin username.
This commit is contained in:
parent
e31181c676
commit
faf6438852
@ -37,17 +37,18 @@ export default function AccountSettings() {
|
|||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
||||||
const Buttons = row =>
|
const Buttons = row => (
|
||||||
row.username !== 'admin' ? (
|
|
||||||
<ButtonLayout align="right">
|
<ButtonLayout align="right">
|
||||||
<Button icon={<Pen />} size="small" onClick={() => setEditAccount(row)}>
|
<Button icon={<Pen />} size="small" onClick={() => setEditAccount(row)}>
|
||||||
<FormattedMessage id="label.edit" defaultMessage="Edit" />
|
<FormattedMessage id="label.edit" defaultMessage="Edit" />
|
||||||
</Button>
|
</Button>
|
||||||
|
{!row.is_admin && (
|
||||||
<Button icon={<Trash />} size="small" onClick={() => setDeleteAccount(row)}>
|
<Button icon={<Trash />} size="small" onClick={() => setDeleteAccount(row)}>
|
||||||
<FormattedMessage id="label.delete" defaultMessage="Delete" />
|
<FormattedMessage id="label.delete" defaultMessage="Delete" />
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
</ButtonLayout>
|
</ButtonLayout>
|
||||||
) : null;
|
);
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
@ -230,7 +230,16 @@ export async function saveEvent(website_id, session_id, url, event_type, event_v
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getAccounts() {
|
export async function getAccounts() {
|
||||||
return runQuery(prisma.account.findMany());
|
return runQuery(
|
||||||
|
prisma.account.findMany({
|
||||||
|
orderBy: [
|
||||||
|
{ is_admin: 'desc' },
|
||||||
|
{
|
||||||
|
username: 'asc',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAccountById(user_id) {
|
export async function getAccountById(user_id) {
|
||||||
|
@ -23,10 +23,7 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
// Only admin can change these fields
|
// Only admin can change these fields
|
||||||
if (current_user_is_admin) {
|
if (current_user_is_admin) {
|
||||||
// Cannot change username of admin
|
|
||||||
if (username !== 'admin') {
|
|
||||||
data.username = username;
|
data.username = username;
|
||||||
}
|
|
||||||
data.is_admin = is_admin;
|
data.is_admin = is_admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +34,7 @@ export default async (req, res) => {
|
|||||||
return badRequest(res, 'Account already exists');
|
return badRequest(res, 'Account already exists');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('------------------\n', data);
|
||||||
const updated = await updateAccount(user_id, data);
|
const updated = await updateAccount(user_id, data);
|
||||||
|
|
||||||
return ok(res, updated);
|
return ok(res, updated);
|
||||||
|
Loading…
Reference in New Issue
Block a user