PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/OpenVBX/controllers/auth/reset.php

https://github.com/Codedninja/OpenVBX
PHP | 82 lines | 51 code | 12 blank | 19 comment | 5 complexity | bfdfe04da282aa669ce5c8b579358e49 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * "The contents of this file are subject to the Mozilla Public License
  4. * Version 1.1 (the "License"); you may not use this file except in
  5. * compliance with the License. You may obtain a copy of the License at
  6. * http://www.mozilla.org/MPL/
  7. * Software distributed under the License is distributed on an "AS IS"
  8. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  9. * License for the specific language governing rights and limitations
  10. * under the License.
  11. * The Original Code is OpenVBX, released June 15, 2010.
  12. * The Initial Developer of the Original Code is Twilio Inc.
  13. * Portions created by Twilio Inc. are Copyright (C) 2010.
  14. * All Rights Reserved.
  15. * Contributor(s):
  16. **/
  17. class Reset extends MY_Controller
  18. {
  19. protected $user_id;
  20. function __construct()
  21. {
  22. parent::__construct();
  23. $this->config->load('openvbx');
  24. $this->load->database();
  25. $this->template->write('title', '');
  26. $this->user_id = $this->session->userdata('user_id');
  27. }
  28. public function index()
  29. {
  30. return $this->reset();
  31. }
  32. private function reset()
  33. {
  34. $this->template->write('title', 'Reset Password');
  35. $data = array();
  36. $email = $this->input->post('email');
  37. if(empty($email))
  38. {
  39. $data['error'] = $this->session->flashdata('error');
  40. return $this->respond('', 'reset', $data, 'login-wrapper', 'layout/login');
  41. }
  42. $user = VBX_User::get(array('email' => $this->input->post('email'),
  43. 'is_active' => 1,
  44. ));
  45. if(empty($user))
  46. {
  47. $this->session->set_flashdata('error',
  48. 'No active account found.');
  49. return redirect('auth/reset');
  50. }
  51. if($user->auth_type == 'google')
  52. {
  53. header('Location: http://www.google.com/support/accounts/bin/answer.py?answer=48598&hl=en&ctx=ch_Login&fpUrl=https%3A%2F%2Fwww.google.com%2Faccounts%2FForgotPasswd%3FfpOnly%3D1%26continue%3Dhttp%253A%252F%252Fwww.google.com%252F%26hl%3Den');
  54. return;
  55. }
  56. else
  57. {
  58. $user = new VBX_User($user);
  59. $user->set_password();
  60. $this->session->set_flashdata('error',
  61. 'An email has been sent, check your inbox.');
  62. return redirect('auth/login');
  63. }
  64. return redirect('auth/reset');
  65. }
  66. }