How to enable users to access their user data in firebase

These are my firebase realtime database rules;

{
  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
 
  "rules": {
    "users": {
      "$uid": {
        ".read": "auth.id === $uid",
        ".write": "auth.id === $uid"
      }
    }
  } 
}

Now; I want when the user logs in, he should be able access his user data.

However at the moment am getting the access denied response that the client does’nt have the required permissions to access the desired data and yet he has successfully logged in.

Help me on how I can enable users to read their user data on login;

The following is my attempt;

//my web app's Firebase configuration
var firebaseConfig = {
      // my configurations
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Initialize variables
const auth = firebase.auth()
const database = firebase.database()




// Set up our login function
function login () {
  // Get all our input fields
  email = document.getElementById('email').value
  password = document.getElementById('password').value

  // Validate input fields
  if (validate_email(email) == false || validate_password(password) == false) {
    alert('Email or Password is Outta Line!!')
    return
    // Don't continue running the code
  }
  

  var database_ref = database.ref()
  auth.signInWithEmailAndPassword(email, password)
  .then(function() {
    // Declare user variable
    var user = auth.currentUser
    
    
    // Create User data
    var user_data = {
      last_login : Date.now()
    }
    
    // Push to Firebase Database
    database_ref.child('users/' + user.uid).update(user_data)
    
    
    
    const usersRef = database.ref('users');
    const userRef = usersRef.child(user.uid);
        
        
    // Add this user to Firebase Database
        //var database_ref = database.ref()
    
    userRef.once('value')
      .then(snapshot => {
        const userData = snapshot.val();
        alert(userData); // Access the retrieved user data
      })
      .catch(error => {
        alert(error);
      });
    

    
    
    // DOne
    alert('User Logged In!! && verified ' + user.emailVerified + " usernameIs "+ JSON.stringify(user.uid))

  })
  .catch(function(error) {
    // Firebase will use this to alert of its errors
    var error_code = error.code
    var error_message = error.message

    alert(error_message)
  })
}