diff --git a/application/api/auth.2/signin.js b/application/api/auth.2/signin.js index 29e02702..9e6d600d 100644 --- a/application/api/auth.2/signin.js +++ b/application/api/auth.2/signin.js @@ -2,10 +2,10 @@ access: 'public', method: async ({ login, password }) => { const user = await api.auth.provider.getUser(login); - if (!user) throw new Error('Incorrect login or password'); + if (!user) throw new Error('Incorrect login or password', 403); const { accountId, password: hash } = user; const valid = await metarhia.metautil.validatePassword(password, hash); - if (!valid) throw new Error('Incorrect login or password'); + if (!valid) throw new Error('Incorrect login or password', 403); console.log(`Logged user: ${login}`); const token = api.auth.provider.generateToken(); const data = { accountId: user.accountId }; diff --git a/application/db/pg/start.js b/application/db/pg/start.js index 43b60982..ce0d9ee7 100644 --- a/application/db/pg/start.js +++ b/application/db/pg/start.js @@ -4,4 +4,12 @@ async () => { } const options = { ...config.database, console }; db.pg = new metarhia.metasql.Database(options); + + // Check that we connected successfully. + await db.pg.query('SELECT now()').catch((err) => { + if (application.worker.id === 'W1') { + console.error(`Failed to setup DB: ${err.message}`); + } + process.exit(0); + }); };