test language, make pubkey unique, migrations dir from config

This commit is contained in:
Moriz Wahl 2021-12-28 17:36:41 +01:00
parent dc6459f45c
commit 5c79d34ef3
3 changed files with 22 additions and 2 deletions

View File

@ -185,6 +185,25 @@ describe('UserResolver', () => {
)
})
})
describe('unknown language', () => {
it('sets "de" as default language', async () => {
await mutate({
mutation,
variables: { ...variables, email: 'bibi@bloxberg.de', language: 'es' },
})
await expect(
getRepository(LoginUser).createQueryBuilder('login_user').getMany(),
).resolves.toEqual(
expect.arrayContaining([
expect.objectContaining({
email: 'bibi@bloxberg.de',
language: 'de',
}),
]),
)
})
})
})
})

View File

@ -26,6 +26,7 @@ import { signIn } from '../../apis/KlicktippController'
import { RIGHTS } from '../../auth/RIGHTS'
import { ServerUserRepository } from '../../typeorm/repository/ServerUser'
import { ROLE_ADMIN } from '../../auth/ROLES'
import { randomBytes } from 'crypto'
const EMAIL_OPT_IN_RESET_PASSWORD = 2
const EMAIL_OPT_IN_REGISTER = 1
@ -432,7 +433,7 @@ export class UserResolver {
dbUser.lastName = lastName
dbUser.username = username
// TODO this field has no null allowed unlike the loginServer table
dbUser.pubkey = Buffer.alloc(32, 0) // default to 0000...
dbUser.pubkey = Buffer.from(randomBytes(32)) // Buffer.alloc(32, 0) default to 0000...
// dbUser.pubkey = keyPair[0]
await queryRunner.manager.save(dbUser).catch((er) => {

View File

@ -18,7 +18,7 @@ const migration = new Migration({
conn: pool,
tableName: CONFIG.MIGRATIONS_TABLE,
silent: true,
dir: '../database/migrations/', // CONFIG.MIGRATIONS_DIRECTORY,
dir: CONFIG.MIGRATIONS_DIRECTORY,
})
const initialize = async (): Promise<void> => {