2013-03-19 45 views
1

我需要爲失去密碼的用戶生成令牌/驗證碼,但我不能依賴現有的Joomla安裝,因爲1)它是一個非常老的Joomla安裝(1.5.15),2)這是我的項目需求之一。我不能碰任何東西,因爲它是第三方工作,但我需要爲移動用戶(現在是iOS和Android)實施密碼恢復系統,並且我需要知道密碼恢復系統使用哪種算法。爲丟失的密碼生成驗證碼?

誰能告訴我它是如何工作的?

回答

2

在的Joomla您可以檢查以下文件

components/com_users/controller/reset.php 
components/com_users/modles/reset.php 

在控制器文件,你可以找到一個函數名request();

它使用的函數模型processResetRequest();

在側,此功能將創建帶有以下代碼的激活令牌

 // Set the confirmation token. 
$token = JUtility::getHash(JUserHelper::genRandomPassword()); 
$salt = JUserHelper::getSalt('crypt-md5'); 
$hashedToken = md5($token.$salt).':'.$salt; 

$user->activation = $hashedToken; 

此外joomla正在驗證令牌的正確性,然後它將允許用戶創建新的密碼。如果你想這樣做,你可以使用下面的代碼爲joomla標準密碼。

jimport('joomla.user.helper'); 
$salt = JUserHelper::genRandomPassword(32); 
$crypt = JUserHelper::getCryptedPassword($password_choose, $salt); 
$password = $crypt.':'.$salt; 

上述代碼正在創建joomla密碼。

如果你打算用這個移動設備和無需編輯核心的Joomla中,您可以創建在根文件,並實現它像this

希望這可以幫助你..

+0

究竟是什麼我在尋找。非常感謝! :) – 2013-03-19 12:11:53

+0

很高興聽到它可以幫助你好運。 – 2013-03-19 13:46:21