diff --git a/src/model/Repositories/UserEmailConfirmationsRepository.php b/src/model/Repositories/UserEmailConfirmationsRepository.php
index <HASH>..<HASH> 100644
--- a/src/model/Repositories/UserEmailConfirmationsRepository.php
+++ b/src/model/Repositories/UserEmailConfirmationsRepository.php
@@ -21,7 +21,7 @@ class UserEmailConfirmationsRepository extends Repository
 
     public function confirm(string $token): ?ActiveRow
     {
-        $emailConfirmationRow = $this->getTable()->where('token', $token)->fetch();
+        $emailConfirmationRow = $this->getTable()->where('token', $token)->order('id DESC')->fetch();
         if (!$emailConfirmationRow) {
             return null;
         }
@@ -32,10 +32,14 @@ class UserEmailConfirmationsRepository extends Repository
 
         return $emailConfirmationRow;
     }
-    
+
     public function getToken(int $userId): ?string
     {
-        $token = $this->getTable()->where('user_id', $userId)->fetchField('token');
+        $token = $this->getTable()
+            ->where('user_id', $userId)
+            ->order('id DESC')
+            ->fetchField('token');
+
         return $token ?: null;
     }
 }
Add automatic internal user confirmation

At this point we want to maintain backwards compatibility
and confirm every user. Once we start sending activation
links to the selected groups of users, we'll exclude
this groups from the automatic user confirmation.

remp/crm#<I>