1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

Merge branch 'master' into fix/dont-wait-on-email-server

This commit is contained in:
Christopher Kolstad 2021-04-26 14:38:23 +02:00 committed by GitHub
commit a5ee70df3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 15 deletions

View File

@ -1,7 +1,7 @@
{
"name": "unleash-server",
"description": "Unleash is an enterprise ready feature toggles service. It provides different strategies for handling feature toggles.",
"version": "4.0.0-alpha.3",
"version": "4.0.0-alpha.4",
"keywords": [
"unleash",
"feature toggle",
@ -113,6 +113,7 @@
"@types/bcrypt": "^3.0.0",
"@types/express": "^4.17.11",
"@types/node": "^14.14.37",
"@types/node-fetch": "^2.5.10",
"@types/nodemailer": "^6.4.1",
"@types/owasp-password-strength-test": "^1.3.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",

View File

@ -57,7 +57,7 @@ test('Should create default user', async t => {
await service.initAdminUser();
const user = await service.loginUser('admin', 'admin');
const user = await service.loginUser('admin', 'unleash4all');
t.is(user.username, 'admin');
});

View File

@ -9,7 +9,6 @@ import { Logger } from '../logger';
import User, { IUser } from '../types/user';
import isEmail from '../util/is-email';
import { AccessService, RoleName } from './access-service';
import { ADMIN } from '../permissions';
import ResetTokenService from './reset-token-service';
import InvalidTokenError from '../error/invalid-token-error';
import NotFoundError from '../error/notfound-error';
@ -75,14 +74,7 @@ class UserService {
getLogger,
authentication,
}: Pick<IUnleashConfig, 'getLogger' | 'authentication'>,
{
accessService,
resetTokenService,
emailService,
}: Pick<
IServices,
'accessService' | 'resetTokenService' | 'emailService'
>,
{ accessService, resetTokenService, emailService }: IServices,
) {
this.logger = getLogger('service/user-service.js');
this.store = stores.userStore;
@ -107,13 +99,14 @@ class UserService {
if (!hasAdminUser) {
// create default admin user
try {
const pwd = 'unleash4all';
this.logger.info(
'Creating default user "admin" with password "admin"',
`Creating default user "admin" with password "${pwd}"`,
);
const user = await this.store.insert({
username: 'admin',
});
const passwordHash = await bcrypt.hash('admin', saltRounds);
const passwordHash = await bcrypt.hash(pwd, saltRounds);
await this.store.setPasswordHash(user.id, passwordHash);
const rootRoles = await this.accessService.getRootRoles();

View File

@ -12,4 +12,6 @@ exports.up = function(db, cb) {
);
};
exports.down = function() {};
exports.down = function(db, cb) {
db.runSql('', cb);
};

View File

@ -46,7 +46,7 @@ test.afterEach(async () => {
test.serial('should create initial admin user', async t => {
await userService.initAdminUser();
await t.notThrowsAsync(userService.loginUser('admin', 'admin'));
await t.notThrowsAsync(userService.loginUser('admin', 'unleash4all'));
await t.throwsAsync(userService.loginUser('admin', 'wrong-password'));
});

View File

@ -590,6 +590,14 @@
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
"@types/node-fetch@^2.5.10":
version "2.5.10"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"
integrity sha512-IpkX0AasN44hgEad0gEF/V6EgR5n69VEqPEgnmoM8GsIGro3PowbWs4tR6IhxUTyPLpOn+fiGG6nrQhcmoCuIQ==
dependencies:
"@types/node" "*"
form-data "^3.0.0"
"@types/node@*":
version "14.0.27"
resolved "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz"