diff --git a/services/accountRegistrationService.js b/services/accountRegistrationService.js index 1ce8c88..96f6d5c 100644 --- a/services/accountRegistrationService.js +++ b/services/accountRegistrationService.js @@ -264,13 +264,9 @@ class AccountRegistration { logger.info(`-__-__-__-__-__-__-__-__-__-__-__-__-__-__-__--`); logger.info(` NEXT: Set The Alias`); logger.info(`-__-__-__-__-__-__-__-__-__-__-__-__-__-__-__--\n`); - await this.jupApi.setAlias(newAccountProperties.address, newAccountProperties.passphrase, newAccountAliasName); - // Fifth: Create the binaryAccount - // console.log(`\n`); - // logger.info(`-__-__-__-__-__-__-__-__-__-__-__-__-__-__-__--`); - // logger.info(` Fifth: Create the binaryAccount`); - // logger.info(`-__-__-__-__-__-__-__-__-__-__-__-__-__-__-__--\n`); - // this.binaryAccountJob.create(newAccountProperties); + const aliasResponse = await this.jupApi.setAlias(newAccountProperties.address, newAccountProperties.passphrase, newAccountAliasName); + await this.jupiterFundingService.waitForTransactionConfirmation(aliasResponse.data.transaction); + return; }catch(error){ logger.error(`****************************************************************`); diff --git a/src/metis/routes/login.js b/src/metis/routes/login.js index 4113de1..69aa5ea 100644 --- a/src/metis/routes/login.js +++ b/src/metis/routes/login.js @@ -54,12 +54,21 @@ module.exports = (app, jobs, websocket) => { const privateKeyBuffer = Buffer.from(jwtPrivateKeyBase64String, 'base64'); const jwtCrypto = new GravityCrypto(metisConf.appPasswordAlgorithm,privateKeyBuffer); const userAccountProperties = await jupiterAccountService.getMemberAccountPropertiesFromPersistedUserRecordOrNull(passphrase, password); - if (userAccountProperties === null) { + if (!userAccountProperties) { return res.status(StatusCode.ClientErrorBadRequest).send({ message: 'Not able to authenticate.', code: MetisErrorCode.MetisErrorFailedUserAuthentication }); } + + const userAlias = userAccountProperties.getCurrentAliasNameOrNull(); + if(!userAlias){ + return res.status(StatusCode.ClientErrorBadRequest).send({ + message: 'Not alias found.', + code: MetisErrorCode.MetisErrorAccountHasNoAlias + }); + } + const jwtContent = { passphrase: passphrase, password: password, @@ -79,8 +88,7 @@ module.exports = (app, jobs, websocket) => { testCounter = testCounter + 1; const user = { address: userAccountProperties.address, - alias: userAccountProperties.getCurrentAliasNameOrNull(), - profileUrl: 'http://bla.bla', //TODO get the profile url + alias: userAlias, }; return res.status(StatusCode.SuccessOK).send({ user, diff --git a/utils/metisErrorCode.js b/utils/metisErrorCode.js index ce56102..89633bd 100644 --- a/utils/metisErrorCode.js +++ b/utils/metisErrorCode.js @@ -36,4 +36,5 @@ module.exports.MetisErrorCode = { MetisErrorSendMessageToJupiterFailed: 16028, MetisErrorFileTooLarge: 16029, MetisErrorJupiterUnknownTransaction: 16030, + MetisErrorAccountHasNoAlias: 16031, }