public function on_page_load() { $email_ctx_id = $this->get('email_id_ctx', 'email'); $email = $this->_ctx->get($email_ctx_id); $referrer_page = Request::current()->referrer(); $next_page = $this->get('next_url', Request::current()->referrer()); if (!Valid::email($email)) { Messages::errors(__('Use a valid e-mail address.')); HTTP::redirect($referrer_page); } $user = ORM::factory('user', array('email' => $email)); if (!$user->loaded()) { Messages::errors(__('No user found!')); HTTP::redirect($referrer_page); } $reflink = ORM::factory('user_reflink')->generate($user, 'forgot', array('next_url' => URL::site($this->next_url, TRUE))); if (!$reflink) { Messages::errors(__('Reflink generate error')); HTTP::redirect($referrer_page); } Observer::notify('admin_login_forgot_before', $user); try { Email_Type::get('user_request_password')->send(array('username' => $user->username, 'email' => $user->email, 'reflink' => Route::url('reflink', array('code' => $reflink)), 'code' => $reflink)); Messages::success(__('Email with reflink send to address set in your profile')); } catch (Exception $e) { Messages::error(__('Something went wrong')); } HTTP::redirect($next_page); }
public function confirm() { $new_password = Text::random(); $this->_model->user->change_email($new_password); try { Email_Type::get('user_new_password')->send(array('username' => $this->_model->user->username, 'email' => $this->_model->user->email, 'password' => $new_password)); Messages::success(__('An email has been send with your new password!')); $this->_model->delete(); return TRUE; } catch (Kohana_Exception $e) { throw new Reflink_Exception('Email :email not send', array(':email' => $this->_model->user->email)); } }
public function confirm() { try { $role = ORM::factory('role', array('name' => 'login')); $this->_model->user->add('roles', $role); Email_Type::get('user_registered')->send(array('username' => $this->_model->user->username, 'email' => $this->_model->user->email)); Messages::success(__('Thank you for registration!')); $this->_model->delete(); return TRUE; } catch (Kohana_Exception $e) { throw new Reflink_Exception('Something went wrong'); } }
/** * Запуск почтового уведомления * * @return boolean */ public function handle_email_type(array $values) { return Email_Type::get($this->get_hash())->send($values); }