Overview

Namespaces

  • Cron
  • None

Classes

  • _HtmlGrid_TableOut
  • _TransactionModel_RawSaveOperation
  • AccessControlComponent
  • AccessControlHelper
  • ActionListHelper
  • ActiveDirectoryUtils
  • AddCurrentPidToSchedulingShellCallLogs
  • AnonymousFunctionOperation
  • ArrayUtil
  • AssociationIntegrityBehavior
  • AtomicOperation
  • AuthenticationComponent
  • AuthenticationController
  • AuthenticationUser
  • AutocompleteDatasourceComponent
  • BaseModelComponent
  • Basics
  • CakeLayersHelper
  • CheckAndRunShell
  • ClassSearcher
  • CommandLineUtil
  • CommonValidationBehavior
  • ConfigurableShellCallsSchedulingTask
  • ConfigurationKey
  • ConfigurationKeys
  • ConfigurationKeysController
  • Context
  • ContextComponent
  • ContextHelper
  • Contexts
  • ControllerInspector
  • ControllerMenuHelper
  • CreateJournalingTables
  • CreateTableConfigurationKeys
  • CreateTableSchedulingConfigurableShellCalls
  • CreateTableSchedulingShellCallLogs
  • CreateTableSettedConfigurationKeys
  • CreateTableUserResetPasswordRequests
  • CreateTableUsers
  • CronSchedulingInstaller
  • CronValidationBehavior
  • CssBox
  • CssController
  • CssProperties
  • CssShell
  • CsvUtil
  • CustomDataModel
  • DatasourceDumperManager
  • DateTimeInput
  • DependencyShell
  • DetailHelper
  • DumperShell
  • ExtendedFieldsAccessControl
  • ExtendedFieldSet
  • ExtendedFieldSetHelper
  • ExtendedFieldsParser
  • ExtendedFormHelper
  • ExtendedHasManyAppModel
  • ExtendedOperationsBehavior
  • FieldDefinition
  • FieldRowDefinition
  • FieldSetDefinition
  • FieldSetLayoutHelper
  • FileOperations
  • FileOperations_Rename
  • FileOperations_SymLink
  • FileOperations_Touch
  • FileOperations_Unlink
  • FileSystem
  • FixConfigurationKeysPrimaryKey
  • FixSettedConfigurationKeysPrimaryKey
  • HasManyUtilsBehavior
  • HtmlDocument
  • HtmlGrid
  • HtmlGrid_Cell
  • HttpClient
  • HttpResponse
  • ImapClient
  • ImapMailBox
  • ImapParserShell
  • IncludePath
  • InputMasked
  • InputSearchable
  • InputsOnSubmit
  • InstallShell
  • JenkinsBuildShell
  • Journal
  • JournalDetail
  • JournalizedBehavior
  • JsonResponseComponent
  • LayoutsHelper
  • Ldap
  • LdapUtils
  • ListFieldSet
  • ListFieldSetHelper
  • ListsHelper
  • MailParser
  • Make
  • MenuHelper
  • MigrationAllPluginsShell
  • ModelOperations
  • ModelOperations_Delete
  • ModelOperations_Save
  • ModelTraverser
  • MysqlDumper
  • OpenLdapUtils
  • PaginatorUtilComponent
  • PaginatorUtilComponentFilter
  • PaginatorUtilHelper
  • Plugin
  • PluginManager
  • Reflections
  • RenameEnabledToActiveFromUsersTable
  • RunShellCallShell
  • ScaffoldUtilComponent
  • ScaffoldUtilHelper
  • Scheduling
  • SchedulingConfigurableShellCall
  • SchedulingConfigurableShellCallsController
  • SchedulingShellCallLog
  • SchedulingShellCallLogsController
  • SettedConfigurationKey
  • StuffreposPluginsRename
  • TimeZoneBehavior
  • TransactionModel
  • TransactionOperation
  • Translator
  • TranslatorShell
  • User
  • UserAuthenticationComponent
  • UserChangePassword
  • UserResetPassword
  • UserResetPasswordRequest
  • UserResetPasswordRequestSubmission
  • UsersController
  • ViewUtilHelper

Interfaces

  • AccessControlFilter
  • CommitableOperation
  • DatasourceDumper
  • MakeListener
  • SchedulingInstaller
  • TasksObject
  • UndoableOperation

Exceptions

  • LdapObjectNotWritableException
  • ModelTraverserException
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: App::uses('AppModel', 'Model');
 4: 
 5: class AuthenticationUser extends AppModel {
 6: 
 7:     private static $settings;
 8: 
 9:     public static function configure($settings) {
10:         self::$settings = $settings;
11:     }
12: 
13:     public $useTable = false;
14: 
15:     public function findByUsername($username) {
16:         return $this->_findBy(self::$settings['usernameField'], $username);
17:     }
18: 
19:     public function findByEmail($email) {
20:         return $this->_findBy(self::$settings['emailField'], $email);
21:     }
22: 
23:     public function findById($id) {
24:         $model = ClassRegistry::init(self::$settings['userModel']);
25:         return $this->_findBy($model->primaryKey, $id);
26:     }
27: 
28:     public function changePassword($id, $password) {
29:         $model = ClassRegistry::init(self::$settings['userModel']);
30:         $user = $model->find(
31:                 'first', array(
32:             'conditions' => array(
33:                 "{$model->alias}.{$model->primaryKey}" => $id
34:             )
35:         ));
36:         $user[$model->alias][self::$settings['passwordField']] = $password;
37:         return $model->save($user);
38:     }
39: 
40:     private function _findBy($field, $value) {
41:         $model = ClassRegistry::init(self::$settings['userModel']);
42:         $result = $model->find(
43:                 'first', array(
44:             'conditions' => array(
45:                 "{$model->alias}.$field" => $value
46:             )
47:         ));
48:         return $this->_toAuthenticationUser($result);
49:     }
50: 
51:     private function _toAuthenticationUser($user) {
52:         if (empty($user)) {
53:             return false;
54:         } else {
55:             $model = ClassRegistry::init(self::$settings['userModel']);
56:             return array(
57:                 $this->alias => array(
58:                     'id' => $user[$model->alias][$model->primaryKey],
59:                     'username' => $user[$model->alias][self::$settings['usernameField']],
60:                     'email' => $user[$model->alias][self::$settings['emailField']],
61:                     'active' => $user[$model->alias][self::$settings['activeField']],
62:                     'password' => $user[$model->alias][self::$settings['passwordField']],
63:                 )
64:             );
65:         }
66:     }
67: 
68: }
API documentation generated by ApiGen 2.8.0