Skip to content

Commit

Permalink
Fix alias during sign up and sign in
Browse files Browse the repository at this point in the history
  • Loading branch information
joramirezStackit committed Feb 1, 2022
1 parent 184db88 commit 5bed183
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 3 additions & 7 deletions services/accountRegistrationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`****************************************************************`);
Expand Down
14 changes: 11 additions & 3 deletions src/metis/routes/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions utils/metisErrorCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ module.exports.MetisErrorCode = {
MetisErrorSendMessageToJupiterFailed: 16028,
MetisErrorFileTooLarge: 16029,
MetisErrorJupiterUnknownTransaction: 16030,
MetisErrorAccountHasNoAlias: 16031,
}

0 comments on commit 5bed183

Please sign in to comment.