mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Merge ea02f66710 into 777515f754
This commit is contained in:
commit
45c722e96e
5 changed files with 32751 additions and 2 deletions
32585
package-lock.json
generated
Normal file
32585
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -137,6 +137,8 @@
|
|||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@svgr/rollup": "^8.1.0",
|
||||
"@svgr/webpack": "^8.1.0",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.3.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.13.4",
|
||||
"@types/react": "^19.0.8",
|
||||
|
|
@ -159,13 +161,14 @@
|
|||
"extract-react-intl-messages": "^4.1.1",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"lint-staged": "^14.0.1",
|
||||
"postcss": "^8.4.31",
|
||||
"postcss-flexbugs-fixes": "^5.0.2",
|
||||
"postcss-import": "^15.1.0",
|
||||
"postcss-preset-env": "7.8.3",
|
||||
"prettier": "^2.6.2",
|
||||
"prompts": "2.4.2",
|
||||
"prompts": "^2.4.2",
|
||||
"rollup": "^3.28.0",
|
||||
"rollup-plugin-copy": "^3.4.0",
|
||||
"rollup-plugin-delete": "^2.0.0",
|
||||
|
|
@ -178,7 +181,7 @@
|
|||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-recommended": "^14.0.0",
|
||||
"tar": "^6.1.2",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-jest": "^29.3.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.5.3"
|
||||
}
|
||||
|
|
|
|||
57
scripts/change-password.js
Normal file
57
scripts/change-password.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* eslint-disable no-console */
|
||||
require('dotenv').config();
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const prompts = require('prompts');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Function to hash password with bcrypt (replaces imported hashPassword)
|
||||
async function hashPassword(password) {
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
return bcrypt.hash(password, salt);
|
||||
}
|
||||
|
||||
async function changePassword() {
|
||||
console.log('Change user password');
|
||||
console.log('-------------------');
|
||||
|
||||
const { username } = await prompts({
|
||||
type: 'text',
|
||||
name: 'username',
|
||||
message: 'Username:',
|
||||
initial: 'admin',
|
||||
});
|
||||
|
||||
const { password } = await prompts({
|
||||
type: 'password',
|
||||
name: 'password',
|
||||
message: 'New password:',
|
||||
validate: value => (value.length >= 8 ? true : 'Password must be at least 8 characters'),
|
||||
});
|
||||
|
||||
try {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { username },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
console.log(`User not found: ${username}`);
|
||||
return;
|
||||
}
|
||||
const hash = await hashPassword(password);
|
||||
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { password: hash },
|
||||
});
|
||||
|
||||
console.log(`Password changed successfully for ${username}.`);
|
||||
} catch (e) {
|
||||
console.error('Error changing password:', e.message || e);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
changePassword();
|
||||
52
scripts/create-admin.js
Normal file
52
scripts/create-admin.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* eslint-disable no-console */
|
||||
require('dotenv').config();
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Function to hash password with bcrypt
|
||||
function hashPassword(password) {
|
||||
const salt = bcrypt.genSaltSync(10);
|
||||
return bcrypt.hashSync(password, salt);
|
||||
}
|
||||
|
||||
async function createAdmin() {
|
||||
const username = 'admin';
|
||||
const password = 'umami';
|
||||
|
||||
try {
|
||||
// Check if user already exists
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { username },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
console.log(`User ${username} already exists.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new admin user
|
||||
const hash = hashPassword(password);
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
id: uuidv4(),
|
||||
username,
|
||||
password: hash,
|
||||
role: 'admin',
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Admin user created successfully with ID: ${user.id}`);
|
||||
console.log(`Username: ${username}`);
|
||||
console.log(`Admin user ${username} created successfully with ID: ${user.id}`);
|
||||
} catch (e) {
|
||||
console.error('Error creating admin user:', e);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
createAdmin();
|
||||
52
scripts/list-users.js
Normal file
52
scripts/list-users.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* eslint-disable no-console */
|
||||
require('dotenv').config();
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
// Function to hash password with bcrypt
|
||||
function hashPassword(password) {
|
||||
const salt = bcrypt.genSaltSync(10);
|
||||
return bcrypt.hashSync(password, salt);
|
||||
}
|
||||
|
||||
async function createAdmin() {
|
||||
const username = 'admin';
|
||||
const password = 'umami';
|
||||
|
||||
try {
|
||||
// Check if user already exists
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { username },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
console.log(`User ${username} already exists.`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new admin user
|
||||
const hash = hashPassword(password);
|
||||
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
id: uuidv4(),
|
||||
username,
|
||||
password: hash,
|
||||
role: 'admin',
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Admin user created successfully with ID: ${user.id}`);
|
||||
console.log(`Username: ${username}`);
|
||||
console.log('Password: [REDACTED]');
|
||||
} catch (e) {
|
||||
console.error('Error creating admin user:', e);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
createAdmin();
|
||||
Loading…
Add table
Add a link
Reference in a new issue