logic/auth.js
// Change the dashboard and system password.
Change the dashboard and system password.
Change the dashboard and system password .
async function changePassword(currentPassword, newPassword, jwt) {
    resetChangePasswordStatus();
    changePasswordStatus.percent = 1; 
    try {
      const user = await diskLogic.readUserFile();
      const credentials = hashCredentials(SYSTEM_USER, newPassword);
      const decryptedSeed = await iocane.createSession().decrypt(user.seed, currentPassword);
      const encryptedSeed = await iocane.createSession().encrypt(decryptedSeed, newPassword);
      await diskLogic.writeUserFile({ ...user, password: credentials.password, seed: encryptedSeed });
      await setSystemPassword(newPassword);
      changePasswordStatus.percent = 100;
      complete = true;
      cachePassword(newPassword);
    } catch (error) {
      changePasswordStatus.percent = 100;
      changePasswordStatus.error = true;
      throw new Error('Unable to change password');
    }
}
async function changePassword ( currentPassword , newPassword , jwt ) { resetChangePasswordStatus ( ) ; changePasswordStatus . percent = 1 ; try { const user = await diskLogic . readUserFile ( ) ; const credentials = hashCredentials ( SYSTEM_USER , newPassword ) ; const decryptedSeed = await iocane . createSession ( ) . decrypt ( user . seed , currentPassword ) ; const encryptedSeed = await iocane . createSession ( ) . encrypt ( decryptedSeed , newPassword ) ; await diskLogic . writeUserFile ( { ... user , password : credentials . password , seed : encryptedSeed } ) ; await setSystemPassword ( newPassword ) ; changePasswordStatus . percent = 100 ; complete = true ; cachePassword ( newPassword ) ; } catch ( error ) { changePasswordStatus . percent = 100 ; changePasswordStatus . error = true ; throw new Error ( 'Unable to change password' ) ; } }
Change the dashboard and system password.
Change the dashboard and system password .
// eslint-disable-line no-magic-numbers // update user file // re-encrypt seed with new password // update user file // update system password // cache the password for later use