mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
do not generate a password for a user, but change the process to set the password later.
This commit is contained in:
parent
f6f6314eb1
commit
a6e4e84c9b
@ -12,10 +12,7 @@ export default class CreateUserArgs {
|
|||||||
lastName: string
|
lastName: string
|
||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
password: string
|
language?: string // Will default to DEFAULT_LANGUAGE
|
||||||
|
|
||||||
@Field(() => String)
|
|
||||||
language?: string
|
|
||||||
|
|
||||||
@Field(() => Int, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
publisherId: number
|
publisherId: number
|
||||||
|
|||||||
@ -274,7 +274,7 @@ export class UserResolver {
|
|||||||
|
|
||||||
@Mutation(() => String)
|
@Mutation(() => String)
|
||||||
async createUser(
|
async createUser(
|
||||||
@Args() { email, firstName, lastName, password, language, publisherId }: CreateUserArgs,
|
@Args() { email, firstName, lastName, language, publisherId }: CreateUserArgs,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// TODO: wrong default value (should be null), how does graphql work here? Is it an required field?
|
// TODO: wrong default value (should be null), how does graphql work here? Is it an required field?
|
||||||
// default int publisher_id = 0;
|
// default int publisher_id = 0;
|
||||||
@ -284,12 +284,13 @@ export class UserResolver {
|
|||||||
language = DEFAULT_LANGUAGE
|
language = DEFAULT_LANGUAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Register process
|
||||||
// Validate Password
|
// Validate Password
|
||||||
if (!isPassword(password)) {
|
// if (!isPassword(password)) {
|
||||||
throw new Error(
|
// throw new Error(
|
||||||
'Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!',
|
// 'Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!',
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Validate username
|
// Validate username
|
||||||
// TODO: never true
|
// TODO: never true
|
||||||
@ -307,11 +308,13 @@ export class UserResolver {
|
|||||||
throw new Error(`User already exists.`)
|
throw new Error(`User already exists.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const passphrase = PassphraseGenerate()
|
// TODO: Register process
|
||||||
const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key
|
// const passphrase = PassphraseGenerate()
|
||||||
const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
|
// const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key
|
||||||
|
// const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
|
||||||
|
// const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
||||||
|
|
||||||
const emailHash = getEmailHash(email)
|
const emailHash = getEmailHash(email)
|
||||||
const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
|
||||||
|
|
||||||
// Table: login_users
|
// Table: login_users
|
||||||
const loginUser = new LoginUser()
|
const loginUser = new LoginUser()
|
||||||
@ -320,13 +323,15 @@ export class UserResolver {
|
|||||||
loginUser.lastName = lastName
|
loginUser.lastName = lastName
|
||||||
loginUser.username = username
|
loginUser.username = username
|
||||||
loginUser.description = ''
|
loginUser.description = ''
|
||||||
loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
|
// TODO: Register process
|
||||||
|
// loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
|
||||||
loginUser.emailHash = emailHash
|
loginUser.emailHash = emailHash
|
||||||
loginUser.language = language
|
loginUser.language = language
|
||||||
loginUser.groupId = 1
|
loginUser.groupId = 1
|
||||||
loginUser.publisherId = publisherId
|
loginUser.publisherId = publisherId
|
||||||
loginUser.pubKey = keyPair[0]
|
// TODO: Register process
|
||||||
loginUser.privKey = encryptedPrivkey
|
// loginUser.pubKey = keyPair[0]
|
||||||
|
// loginUser.privKey = encryptedPrivkey
|
||||||
|
|
||||||
const queryRunner = getConnection().createQueryRunner()
|
const queryRunner = getConnection().createQueryRunner()
|
||||||
await queryRunner.connect()
|
await queryRunner.connect()
|
||||||
@ -338,21 +343,24 @@ export class UserResolver {
|
|||||||
throw new Error('insert user failed')
|
throw new Error('insert user failed')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: Register process
|
||||||
// Table: login_user_backups
|
// Table: login_user_backups
|
||||||
const loginUserBackup = new LoginUserBackup()
|
// const loginUserBackup = new LoginUserBackup()
|
||||||
loginUserBackup.userId = loginUserId
|
// loginUserBackup.userId = loginUserId
|
||||||
loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space
|
// loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space
|
||||||
loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
|
// loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
|
||||||
|
|
||||||
await queryRunner.manager.save(loginUserBackup).catch((error) => {
|
// TODO: Register process
|
||||||
// eslint-disable-next-line no-console
|
// await queryRunner.manager.save(loginUserBackup).catch((error) => {
|
||||||
console.log('insert LoginUserBackup failed', error)
|
// // eslint-disable-next-line no-console
|
||||||
throw new Error('insert user backup failed')
|
// console.log('insert LoginUserBackup failed', error)
|
||||||
})
|
// throw new Error('insert user backup failed')
|
||||||
|
// })
|
||||||
|
|
||||||
// Table: state_users
|
// Table: state_users
|
||||||
const dbUser = new DbUser()
|
const dbUser = new DbUser()
|
||||||
dbUser.pubkey = keyPair[0]
|
// TODO: Register process
|
||||||
|
// dbUser.pubkey = keyPair[0]
|
||||||
dbUser.email = email
|
dbUser.email = email
|
||||||
dbUser.firstName = firstName
|
dbUser.firstName = firstName
|
||||||
dbUser.lastName = lastName
|
dbUser.lastName = lastName
|
||||||
|
|||||||
@ -138,18 +138,12 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate a random password - 8 random bytes, the email, special char, capital & small letter, number and another set of 8 random bytes
|
|
||||||
// TODO: The user will be forced to reset his password - how was this done before?
|
|
||||||
const password =
|
|
||||||
randomBytes(8).toString('hex') + email + '!aA1' + randomBytes(8).toString('hex')
|
|
||||||
|
|
||||||
const userResolver = new UserResolver()
|
const userResolver = new UserResolver()
|
||||||
try {
|
try {
|
||||||
await userResolver.createUser({
|
await userResolver.createUser({
|
||||||
email,
|
email,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
password,
|
|
||||||
publisherId: loginElopgaeBuy.publisherId,
|
publisherId: loginElopgaeBuy.publisherId,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user