Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') or die('No direct script access.');
- class Controller_User_Account extends Controller_Application {
- public function action_new()
- {
- if (Auth::is_logged_in())
- $this->request->redirect(Route::get('home')->uri());
- $user = ORM::factory('user');
- if ($_POST)
- {
- $user->values($_POST);
- if ($user->check())
- {
- try
- {
- $user->save();
- $this->request->redirect(Route::get('home')->uri());
- }
- catch (Kohana_Exception $e)
- {
- throw new Kohana_Exception('Signup error: '.$e->getMessage());
- }
- }
- else
- {
- $signup_errors = $user->validate()->errors('user_account');
- }
- }
- $this->template->breadcrumbs = array('Home' => url::base(), 'Login or Register' => $this->request->uri());
- $this->template->title[] = 'Sign Up';
- $this->template->section = 'login';
- $this->template->content = View::factory('user/login_signup')
- ->set('login_form', array())
- ->set('login_error', NULL)
- ->set('signup_form', $user->as_array())
- ->set('signup_errors', isset($signup_errors) ? $signup_errors : array());
- }
- public function action_confirm_email()
- {
- if (($user_id = Arr::get($_GET, 'user_id')) AND ($email = Arr::get($_GET, 'email')) AND ($confirmation_code = Arr::get($_GET, 'confirmation_code')))
- {
- if ($user_email = ORM::factory('user_email')->activate($user_id, $email, $confirmation_code))
- {
- // login user
- Auth::do_login($user_id);
- $this->request->redirect(Session::instance()->get(url::base()));
- }
- else
- throw new ReflectionException("Email confirmation: no match found for $user_id : $email : $confirmation_code");
- }
- throw new ReflectionException('Email confirmation: invalid parameters');
- }
- }
Add Comment
Please, Sign In to add comment