mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into refactor-listUnconfirmedContribution-to-adminListAllContribution
This commit is contained in:
commit
95583bda1c
@ -1,4 +1,5 @@
|
||||
import CONFIG from '@/config'
|
||||
import LogError from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { User } from '@entity/User'
|
||||
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
||||
@ -16,11 +17,10 @@ export const SecretKeyCryptographyCreateKey = (salt: string, password: string):
|
||||
const configLoginAppSecret = Buffer.from(CONFIG.LOGIN_APP_SECRET, 'hex')
|
||||
const configLoginServerKey = Buffer.from(CONFIG.LOGIN_SERVER_KEY, 'hex')
|
||||
if (configLoginServerKey.length !== sodium.crypto_shorthash_KEYBYTES) {
|
||||
logger.error(
|
||||
`ServerKey has an invalid size. The size must be ${sodium.crypto_shorthash_KEYBYTES} bytes.`,
|
||||
)
|
||||
throw new Error(
|
||||
`ServerKey has an invalid size. The size must be ${sodium.crypto_shorthash_KEYBYTES} bytes.`,
|
||||
throw new LogError(
|
||||
'ServerKey has an invalid size',
|
||||
configLoginServerKey.length,
|
||||
sodium.crypto_shorthash_KEYBYTES,
|
||||
)
|
||||
}
|
||||
|
||||
@ -52,20 +52,13 @@ export const SecretKeyCryptographyCreateKey = (salt: string, password: string):
|
||||
|
||||
export const getUserCryptographicSalt = (dbUser: User): string => {
|
||||
switch (dbUser.passwordEncryptionType) {
|
||||
case PasswordEncryptionType.NO_PASSWORD: {
|
||||
logger.error('Password not set for user ' + dbUser.id)
|
||||
throw new Error('Password not set for user ' + dbUser.id) // user has no password
|
||||
}
|
||||
case PasswordEncryptionType.EMAIL: {
|
||||
case PasswordEncryptionType.NO_PASSWORD:
|
||||
throw new LogError('User has no password set', dbUser.id)
|
||||
case PasswordEncryptionType.EMAIL:
|
||||
return dbUser.emailContact.email
|
||||
break
|
||||
}
|
||||
case PasswordEncryptionType.GRADIDO_ID: {
|
||||
case PasswordEncryptionType.GRADIDO_ID:
|
||||
return dbUser.gradidoID
|
||||
break
|
||||
}
|
||||
default:
|
||||
logger.error(`Unknown password encryption type: ${dbUser.passwordEncryptionType}`)
|
||||
throw new Error(`Unknown password encryption type: ${dbUser.passwordEncryptionType}`)
|
||||
throw new LogError('Unknown password encryption type', dbUser.passwordEncryptionType)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user