/OpenVBX/controllers/auth/reset.php
PHP | 82 lines | 51 code | 12 blank | 19 comment | 5 complexity | bfdfe04da282aa669ce5c8b579358e49 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * "The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
-
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- * License for the specific language governing rights and limitations
- * under the License.
- * The Original Code is OpenVBX, released June 15, 2010.
- * The Initial Developer of the Original Code is Twilio Inc.
- * Portions created by Twilio Inc. are Copyright (C) 2010.
- * All Rights Reserved.
- * Contributor(s):
- **/
- class Reset extends MY_Controller
- {
- protected $user_id;
- function __construct()
- {
- parent::__construct();
- $this->config->load('openvbx');
- $this->load->database();
- $this->template->write('title', '');
- $this->user_id = $this->session->userdata('user_id');
- }
- public function index()
- {
- return $this->reset();
- }
-
- private function reset()
- {
- $this->template->write('title', 'Reset Password');
- $data = array();
- $email = $this->input->post('email');
-
- if(empty($email))
- {
- $data['error'] = $this->session->flashdata('error');
- return $this->respond('', 'reset', $data, 'login-wrapper', 'layout/login');
- }
-
- $user = VBX_User::get(array('email' => $this->input->post('email'),
- 'is_active' => 1,
- ));
- if(empty($user))
- {
- $this->session->set_flashdata('error',
- 'No active account found.');
-
- return redirect('auth/reset');
- }
-
- if($user->auth_type == 'google')
-
- {
- 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');
- return;
- }
- else
- {
- $user = new VBX_User($user);
- $user->set_password();
- $this->session->set_flashdata('error',
- 'An email has been sent, check your inbox.');
- return redirect('auth/login');
- }
-
- return redirect('auth/reset');
- }
- }