diff --git a/components/CiiUserIdentity.php b/components/CiiUserIdentity.php
index <HASH>..<HASH> 100644
--- a/components/CiiUserIdentity.php
+++ b/components/CiiUserIdentity.php
@@ -160,7 +160,10 @@ class CiiUserIdentity extends CUserIdentity
     {
         $otpSeed = $this->getUser()->getMetadataObject('OTPSeed', false)->value;
 
-        $otplib = new TOTP($otpSeed);
+		if ($otpSeed === false)
+			return false;
+		
+        $otplib = new TOTP(Cii::decrypt($otpSeed));
 
         return $otplib->validate($this->twoFactorCode);
     }
TOTP seeds should be encrypted in database