diff --git a/backend/src/graphql/arg/CreateUserArgs.ts b/backend/src/graphql/arg/CreateUserArgs.ts index 906e14aed..0d63e76bb 100644 --- a/backend/src/graphql/arg/CreateUserArgs.ts +++ b/backend/src/graphql/arg/CreateUserArgs.ts @@ -12,10 +12,7 @@ export default class CreateUserArgs { lastName: string @Field(() => String) - password: string - - @Field(() => String) - language?: string + language?: string // Will default to DEFAULT_LANGUAGE @Field(() => Int, { nullable: true }) publisherId: number diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index ba71fef7a..471ca7384 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -274,7 +274,7 @@ export class UserResolver { @Mutation(() => String) async createUser( - @Args() { email, firstName, lastName, password, language, publisherId }: CreateUserArgs, + @Args() { email, firstName, lastName, language, publisherId }: CreateUserArgs, ): Promise { // TODO: wrong default value (should be null), how does graphql work here? Is it an required field? // default int publisher_id = 0; @@ -284,12 +284,13 @@ export class UserResolver { language = DEFAULT_LANGUAGE } + // TODO: Register process // Validate Password - if (!isPassword(password)) { - 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!', - ) - } + // if (!isPassword(password)) { + // 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!', + // ) + // } // Validate username // TODO: never true @@ -307,11 +308,13 @@ export class UserResolver { throw new Error(`User already exists.`) } - const passphrase = PassphraseGenerate() - const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key - const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash + // TODO: Register process + // const passphrase = PassphraseGenerate() + // 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 encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1]) // Table: login_users const loginUser = new LoginUser() @@ -320,13 +323,15 @@ export class UserResolver { loginUser.lastName = lastName loginUser.username = username 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.language = language loginUser.groupId = 1 loginUser.publisherId = publisherId - loginUser.pubKey = keyPair[0] - loginUser.privKey = encryptedPrivkey + // TODO: Register process + // loginUser.pubKey = keyPair[0] + // loginUser.privKey = encryptedPrivkey const queryRunner = getConnection().createQueryRunner() await queryRunner.connect() @@ -338,21 +343,24 @@ export class UserResolver { throw new Error('insert user failed') }) + // TODO: Register process // Table: login_user_backups - const loginUserBackup = new LoginUserBackup() - loginUserBackup.userId = loginUserId - loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space - loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER; + // const loginUserBackup = new LoginUserBackup() + // loginUserBackup.userId = loginUserId + // loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space + // loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER; - await queryRunner.manager.save(loginUserBackup).catch((error) => { - // eslint-disable-next-line no-console - console.log('insert LoginUserBackup failed', error) - throw new Error('insert user backup failed') - }) + // TODO: Register process + // await queryRunner.manager.save(loginUserBackup).catch((error) => { + // // eslint-disable-next-line no-console + // console.log('insert LoginUserBackup failed', error) + // throw new Error('insert user backup failed') + // }) // Table: state_users const dbUser = new DbUser() - dbUser.pubkey = keyPair[0] + // TODO: Register process + // dbUser.pubkey = keyPair[0] dbUser.email = email dbUser.firstName = firstName dbUser.lastName = lastName diff --git a/backend/src/webhook/elopage.ts b/backend/src/webhook/elopage.ts index da9d1a171..90cdb159f 100644 --- a/backend/src/webhook/elopage.ts +++ b/backend/src/webhook/elopage.ts @@ -138,18 +138,12 @@ export const elopageWebhook = async (req: any, res: any): Promise => { 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() try { await userResolver.createUser({ email, firstName, lastName, - password, publisherId: loginElopgaeBuy.publisherId, }) } catch (error) {