当前位置: 首页>>代码示例>>PHP>>正文


PHP VBX_User::set_password方法代码示例

本文整理汇总了PHP中VBX_User::set_password方法的典型用法代码示例。如果您正苦于以下问题:PHP VBX_User::set_password方法的具体用法?PHP VBX_User::set_password怎么用?PHP VBX_User::set_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VBX_User的用法示例。


在下文中一共展示了VBX_User::set_password方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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');
 }
开发者ID:howethomas,项目名称:OpenVBX,代码行数:25,代码来源:reset.php

示例2: save_user

 private function save_user()
 {
     $errors = array();
     $user = false;
     $id = intval($this->input->post('id'));
     $auth_type = $this->input->post('auth_type');
     $error = false;
     $message = "Failed to save user for unknown reason.";
     $shouldGenerateNewPassword = false;
     $device_id_str = trim($this->input->post('device_id'));
     $device_number = trim($this->input->post('device_number'));
     try {
         PhoneNumber::validatePhoneNumber($device_number);
     } catch (PhoneNumberException $e) {
         $data['json'] = array('error' => true, 'message' => $e->getMessage());
         return $this->respond('', 'accounts', $data);
     }
     if (!empty($auth_type)) {
         $auth_type = $this->vbx_user->get_auth_type($auth_type);
     }
     if ($id > 0) {
         $user = VBX_User::get($id);
     } else {
         $user = VBX_User::get(array('email' => $this->input->post('email')));
         if (!empty($user) && $user->is_active == 1) {
             $error = true;
             $message = 'Email address is already in use.';
         } elseif (!empty($user) && $user->is_active == 0) {
             // It's an old account that was made inactive.  By re-adding it, we're
             // assuming the user wants to re-instate the old account.
             $shouldGenerateNewPassword = true;
         } else {
             // It's a new user
             $user = new VBX_User();
             $shouldGenerateNewPassword = true;
         }
     }
     if (!$error) {
         $fields = array('first_name', 'last_name', 'email', 'is_admin');
         foreach ($fields as $field) {
             $user->{$field} = $this->input->post($field);
         }
         $user->is_active = TRUE;
         $user->auth_type = isset($auth_type->id) ? $auth_type->id : 1;
         try {
             $user->save();
             if ($shouldGenerateNewPassword && !$error && !$user->set_password()) {
                 $error = true;
                 $message = "Failed to generate new password.";
             }
         } catch (VBX_UserException $e) {
             $error = true;
             $message = $e->getMessage();
             error_log($message);
         }
         if (!$error) {
             if (strlen($device_number) > 0) {
                 // We're adding or modifying an existing device
                 if (strlen($device_id_str) > 0) {
                     // We're updating an existing record
                     $device_id = intval($device_id_str);
                     $device = VBX_Device::get($device_id);
                     $device->value = normalize_phone_to_E164($device_number);
                     try {
                         $device->save();
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = 'Failed to update device: ' . $e->getMessage();
                     }
                 } else {
                     // We're creating a new device record
                     $number = array("name" => "Primary Device", "value" => normalize_phone_to_E164($device_number), "user_id" => $user->id, "sms" => 1);
                     try {
                         $new_device_id = $this->vbx_device->add($number);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Failed to add device: " . $e->getMessage();
                     }
                 }
             } else {
                 if (strlen($device_number) == 0 && strlen($device_id_str) > 0) {
                     // We're deleting a device
                     try {
                         $this->vbx_device->delete(intval($device_id_str), $user->id);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Unable to delete device entry: " . $e->getMessage();
                     }
                 }
             }
         }
     }
     if ($error) {
         $json = array('error' => $error, 'message' => $message);
     } else {
         $json = array('id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'is_active' => $user->is_active, 'is_admin' => $user->is_admin, 'notification' => $user->notification, 'auth_type' => isset($auth_type->description) ? $auth_type->description : 'openvbx', 'email' => $user->email, 'error' => false, 'message' => '');
     }
     $data['json'] = $json;
     $this->respond('', 'accounts', $data);
 }
开发者ID:howethomas,项目名称:OpenVBX,代码行数:100,代码来源:accounts.php

示例3: add_tenant

 private function add_tenant()
 {
     $tenant = $this->input->post('tenant');
     if (!empty($tenant)) {
         try {
             $data['id'] = $this->settings->tenant($tenant['url_prefix'], urlencode($tenant['url_prefix']), '');
             $user = new VBX_User();
             $user->fields[] = 'tenant_id';
             // monkey patching to override tenant_id
             $user->first_name = '';
             $user->last_name = '';
             $user->password = '';
             $user->values['tenant_id'] = $data['id'];
             $user->email = $tenant['admin_email'];
             $user->is_active = TRUE;
             $user->is_admin = TRUE;
             $user->auth_type = 1;
             try {
                 $user->save();
                 $user->set_password();
             } catch (VBX_UserException $e) {
                 throw new VBX_SettingsException($e->getMessage());
             }
             foreach ($this->settings->setting_options as $param) {
                 $this->settings->add($param, '', $data['id']);
             }
             $this->settings->set('from_email', $tenant['admin_email'], $data['id']);
             if ($tenant['create_subaccount']) {
                 try {
                     $twilio = new TwilioRestClient($this->twilio_sid, $this->twilio_token, $this->twilio_endpoint);
                     $friendlyName = $tenant['url_prefix'] . ' - ' . $tenant['admin_email'];
                     $friendlyName = substr($friendlyName, 0, 32);
                     $response = $twilio->request("Accounts", 'POST', array('FriendlyName' => $friendlyName));
                     if ($response && $response->IsError != true) {
                         $account = $response->ResponseXml;
                         $this->settings->set('twilio_sid', (string) $account->Account->Sid, $data['id']);
                         $this->settings->set('twilio_token', (string) $account->Account->AuthToken, $data['id']);
                     } else {
                         $message = 'Failed to create new subaccount';
                         if ($response && $response->ErrorMessage) {
                             $message = $response->ErrorMessage;
                         }
                         throw new VBX_SettingsException($message);
                     }
                 } catch (Exception $e) {
                     throw new VBX_SettingsException($e->getMessage());
                 }
             }
             $this->session->set_flashdata('error', 'Added new tenant');
         } catch (VBX_SettingsException $e) {
             error_log($e->getMessage());
             $this->session->set_flashdata('error', $e->getMessage());
             $data['error'] = true;
             $data['message'] = $e->getMessage();
         }
         if (isset($data['id'])) {
             return redirect('settings/site/tenant/' . $data['id']);
         }
     }
     if ($this->response_type == 'html') {
         redirect('settings/site');
     }
     $this->respond('', 'settings/site', $data);
 }
开发者ID:howethomas,项目名称:OpenVBX,代码行数:64,代码来源:site.php


注:本文中的VBX_User::set_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。