Form button class update, fixes to module_method_token, fixes to json

This commit is contained in:
Deon George
2011-08-31 16:54:44 +10:00
parent c55a8fe4cc
commit 52074d239b
19 changed files with 62 additions and 60 deletions

View File

@@ -119,6 +119,9 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
* Enable user password reset
*/
public function action_reset() {
// Minutes to keep our token
$token_expire = 15;
// If user already signed-in
if (Auth::instance()->logged_in()!= 0) {
// Redirect to the user account
@@ -138,7 +141,7 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
// Check to see if there is already a token, if so, do nothing.
if ($mt->where('account_id','=',$ao->id)->and_where('method_id','=',$mmo->id)->find()) {
if ($mt->date_expire < time()) {
if ($mt->loaded() AND ($mt->date_expire < time())) {
$mt->delete();
$mt->clear();
}
@@ -147,18 +150,19 @@ class Controller_lnApp_Login extends Controller_TemplateDefault {
if (! $mt->loaded()) {
$mt->account_id = $ao->id;
$mt->method_id = $mmo->id;
$mt->date_expire = time() + 15*3600;
$mt->date_expire = time() + $token_expire*60;
$mt->token = md5(sprintf('%s:%s:%s',$mt->account_id,$mt->method_id,$mt->date_expire));
$mt->save();
// Send our email with the token
$et = Email_Template::instance('account_reset_password');
$et->to = array($mt->account->email=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name));
$et->to = array('account'=>array($mt->account_id));
$et->variables = array(
'SITE'=>URL::base(TRUE,TRUE),
'SITE_ADMIN'=>Config::sitename(),
'SITE_NAME'=>Config::sitename(),
'TOKEN'=>$mt->token,
'TOKEN_EXPIRE_MIN'=>$token_expire,
'USER_NAME'=>sprintf('%s %s',$mt->account->first_name,$mt->account->last_name),
);
$et->send();