public static function VerifyAccount($user_id) { $o = utopia::GetInstance(__CLASS__); $rec = $o->LookupRecord($user_id); // already verified if (!$rec['email_confirm']) { return true; } // account email changed, send $randKey = uCrypt::GetRandom(20); $o->UpdateField('email_confirm_code', $randKey, $user_id); $url = $o->GetURL(array('c' => $randKey)); //$url = preg_replace('/^'.preg_quote(PATH_REL_ROOT,'/').'/','',$url); uNotices::AddNotice('Please check ' . $rec['email_confirm'] . ' for a validation link.'); uEmailer::SendEmailTemplate('account_activate', array('email' => $rec['email_confirm'], 'activate_link' => $url), 'email'); return false; }
public static function CreateSalt() { return '$1$' . uCrypt::GetRandom(12, './abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'); }
public function ResetPW($user) { $rec = $this->LookupRecord(array('username' => $user)); if (!$rec) { return FALSE; } // user not found. // account has not yet been validated. if ($rec['username'] == $rec['email_confirm']) { uVerifyEmail::VerifyAccount($rec['user_id']); return; } $randKey = uCrypt::GetRandom(20); $this->SetFieldOptions('email_confirm_code', ALLOW_EDIT); $this->UpdateField('email_confirm_code', $randKey, $rec['user_id']); $this->SetFieldOptions('email_confirm_code', NULL); //email out verification $name = $rec['username'] ? ' ' . $rec['username'] : ''; $url = $this->GetURL(array('e' => $user, 'c' => $randKey)); $url = preg_replace('/^' . preg_quote(PATH_REL_ROOT, '/') . '/', '', $url); if (empty($rec['password'])) { uEmailer::SendEmailTemplate('account_activate', array('email' => $user, 'contact_name' => $name, 'activate_link' => $url), 'email'); } else { uEmailer::SendEmailTemplate('account_resetpw', array('email' => $user, 'contact_name' => $name, 'activate_link' => $url), 'email'); } }