createNewUser(user, clearPassword) {
    if (user.username.trim() === '') {
      throw new Error('The username is empty.');
    } else if (clearPassword.trim() === '') {
      throw new Error('The password is empty.');
    } else {
      return Promise.resolve()
        .then(() => this.userRepository.create(user))
        .then(() => UserSecurity.hashPassword(clearPassword))
        .then(hash => this.userRepository.changePassword(user, hash))
    }
  }
/**
   * Create a new user in PlanFlix.
   * @param {User} user the new user you want to create
   * @param {String} clearPassword a password of the user
   * @returns {Promise}
   */
Create a new user in PlanFlix.
@param {User} user the new user you want to create
@param {String} clearPassword a password of the user
@returns {Promise}
Create a new user in PlanFlix . @param { User } user the new user you want to create @param { String } clearPassword a password of the user @returns { Promise }
createNewUser(user, clearPassword) {
    if (user.username.trim() === '') {
      throw new Error('The username is empty.');
    } else if (clearPassword.trim() === '') {
      throw new Error('The password is empty.');
    } else {
      return Promise.resolve()
        .then(() => this.userRepository.create(user))
        .then(() => UserSecurity.hashPassword(clearPassword))
        .then(hash => this.userRepository.changePassword(user, hash))
    }
  }
createNewUser ( user , clearPassword ) { if ( user . username . trim ( ) === '' ) { throw new Error ( 'The username is empty.' ) ; } else if ( clearPassword . trim ( ) === '' ) { throw new Error ( 'The password is empty.' ) ; } else { return Promise . resolve ( ) . then ( ( ) => this . userRepository . create ( user ) ) . then ( ( ) => UserSecurity . hashPassword ( clearPassword ) ) . then ( hash => this . userRepository . changePassword ( user , hash ) ) } }
Create a new user in PlanFlix.
Create a new user in PlanFlix .