<?php $uid = \Drupal::service('user.auth')->authenticate($username, $password); if ($uid) { // Başarıyla doğrulandığı takdirde ... }