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