Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2.  
  3. class Controller_User_Account extends Controller_Application {
  4.  
  5. public function action_new()
  6. {
  7. if (Auth::is_logged_in())
  8. $this->request->redirect(Route::get('home')->uri());
  9.  
  10. $user = ORM::factory('user');
  11.  
  12. if ($_POST)
  13. {
  14. $user->values($_POST);
  15.  
  16. if ($user->check())
  17. {
  18. try
  19. {
  20. $user->save();
  21. $this->request->redirect(Route::get('home')->uri());
  22. }
  23. catch (Kohana_Exception $e)
  24. {
  25. throw new Kohana_Exception('Signup error: '.$e->getMessage());
  26. }
  27. }
  28. else
  29. {
  30. $signup_errors = $user->validate()->errors('user_account');
  31. }
  32. }
  33.  
  34. $this->template->breadcrumbs = array('Home' => url::base(), 'Login or Register' => $this->request->uri());
  35. $this->template->title[] = 'Sign Up';
  36. $this->template->section = 'login';
  37. $this->template->content = View::factory('user/login_signup')
  38. ->set('login_form', array())
  39. ->set('login_error', NULL)
  40. ->set('signup_form', $user->as_array())
  41. ->set('signup_errors', isset($signup_errors) ? $signup_errors : array());
  42. }
  43.  
  44. public function action_confirm_email()
  45. {
  46. if (($user_id = Arr::get($_GET, 'user_id')) AND ($email = Arr::get($_GET, 'email')) AND ($confirmation_code = Arr::get($_GET, 'confirmation_code')))
  47. {
  48. if ($user_email = ORM::factory('user_email')->activate($user_id, $email, $confirmation_code))
  49. {
  50. // login user
  51. Auth::do_login($user_id);
  52.  
  53. $this->request->redirect(Session::instance()->get(url::base()));
  54. }
  55. else
  56. throw new ReflectionException("Email confirmation: no match found for $user_id : $email : $confirmation_code");
  57. }
  58.  
  59. throw new ReflectionException('Email confirmation: invalid parameters');
  60. }
  61. }
Add Comment
Please, Sign In to add comment