title: Cakephp 3.x way to check if a user exists in the database
body: <p>I want to create a simple check if a user exists in my database just after he is logged on (LDAP Authentication). If he doesn't exist, a record should be created in the db.
  Is there any standard CakePHP 3.x -way of doing such things?
  Or I can just create a function in my "users" Controller which checks if a user exists in the db and call it in the end of login() function (if user session has been successfully created)?</p>
  
  <pre><code>public function login(){
          if ($this-&gt;request-&gt;is('post')){
              $user = $this-&gt;Auth-&gt;identify();
              if ($user) {
                  $this-&gt;Auth-&gt;setUser($user);
                  $this-&gt;createStudent($user);
                  return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl());
              }
  
              // user is not identified
              $this-&gt;Flash-&gt;error('Your username or password is not correct');
          }
      }
  
  public function createStudent($user){
          $studExists = $this-&gt;Students-&gt;find('isExists', ['uid' =&gt; $user['uid']]);
  
      if (!$studExists) {
          $student = $this-&gt;Students-&gt;newEntity();
          $data = ['id' =&gt; $user['uid']];
          $student = $this-&gt;Students-&gt;patchEntity($student, $data);
          if ($this-&gt;Students-&gt;save($student)) {
              $this-&gt;Flash-&gt;success(__('It is your first logon. You have been added to our database!'));
              return $this-&gt;redirect(['action' =&gt; 'index']);
          } else {
              $this-&gt;Flash-&gt;error(__('You could not be saved in our database. Please, try again.'));
          }
      }
  }
  </code></pre>
  
  <p>Thank you in advance.</p>