Modifying Custom Database scripts

I’m using my user_id from my users table as a foreign key with 5 other tables.

When I try to modify the scripts it doesn’t pull the data related to that email?

Hello @cvasquez0100,

Can you post your custom DB scripts here, or put them online and link to them? Seeing the code (remove any sensitive info of course) would be helpful.

here you go @markd

  • This is the login script.

  • Profile_personals is related to users by using user_id as a foreign key.

    function login(email, password, callback) {

    const connection = mysql({
      host: configuration.DB_HOST,
      user: configuration.DB_USER,
      password: configuration.DB_PASSWORD,
      database: configuration.DB_NAME,
      ssl: {
         rejectUnauthorized: false,
       }
    });
    
    connection.connect();
    
    //const query = 'SELECT user_id, email, phone, linkedin_profile FROM users WHERE email = ?';
    const query = "SELECT user_id, email, password, phone, linkedin_profile, biography FROM users INNER JOIN profile_personals ON users.user_id = profile_personals.fk_user_id WHERE email = ?";
    
    connection.query(query, [ email ], function(err, results) {
      if (err) return callback(err);
      if (results.length === 0) return callback(new WrongUsernameOrPasswordError(email));
      const user = results[0];
    
      bcrypt.compare(password, user.password, function(err, isValid) {
        if (err || !isValid) return callback(err || new WrongUsernameOrPasswordError(email));
    
        callback(null, {
          user_id: user.user_id.toString(),
          email: user.email,
          phone: user.phone,
          linkedin_profile: user.linkedin_profile,
          biography: user.biography
        });
      });
    });
    

    }

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?