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('AuthenticationUser', 'Authentication.Model');
  4: 
  5: class AuthenticationComponent extends Component {
  6: 
  7:     public function __construct(\ComponentCollection $collection, $settings = array()) {
  8:         parent::__construct($collection, $settings + array(
  9:             'emailField' => 'email',
 10:             'usernameField' => 'username',
 11:             'passwordField' => 'password',
 12:             'activeField' => 'active',
 13:             'userModel' => null,
 14:             'loginRedirect' => null,
 15:         ));
 16:         AuthenticationUser::configure($this->settings);
 17:     }
 18: 
 19:     public $components = array(
 20:         'Auth' => array(
 21:             'loginAction' => array(
 22:                 'controller' => 'authentication',
 23:                 'action' => 'login',
 24:                 'plugin' => 'authentication'
 25:             )
 26:         )
 27:     );
 28: 
 29:     public function initialize(\Controller $controller) {
 30:         parent::initialize($controller);
 31:         if (!$controller->Components->loaded('Auth')) {
 32:             $controller->Auth = $controller->Components->load('Auth');
 33:             $controller->Auth->initialize($controller);
 34:         }
 35:         $controller->Auth->authenticate = array(
 36:             'all' => array(
 37:                 'userModel' => $this->settings['userModel'],
 38:                 'fields' => array(
 39:                     'username' => $this->settings['usernameField']
 40:                     , 'password' => $this->settings['passwordField']
 41:                 ),
 42:             ),
 43:             'Form'
 44:         );
 45:         $controller->Auth->authorize = array('Controller');
 46:         $controller->Auth->loginAction = array(
 47:             'controller' => 'authentication',
 48:             'action' => 'login',
 49:             'plugin' => 'authentication'
 50:         );
 51:         $controller->Auth->loginRedirect = $this->settings['loginRedirect'];
 52:         $controller->Auth->allow();
 53:         $controller->Auth->allow('index', 'add', 'edit', 'delete', 'view');
 54:     }
 55: 
 56:     public function sendSelfUserCreationNotification($userId, $password) {
 57:         App::uses('CakeEmail', 'Network/Email');
 58: 
 59:         $model = ClassRegistry::init('Authentication.AuthenticationUser');
 60:         $user = $model->findById($userId);
 61:         $user = $user[$model->alias];
 62: 
 63:         $email = new CakeEmail('default');
 64:         $email->to($user['email']);
 65:         $email->subject(__d('authentication','Your account was created.', true));
 66:         $email->send(
 67:                 __d('authentication','Usernamme') . ': ' . $user['username']
 68:                 . "\n" . __d('authentication','Password') . ': ' . $password);
 69:     }
 70:     
 71:     public function userId() {
 72:         $user = $this->Auth->user();
 73:         return $user[$this->_userModel()->primaryKey];
 74:     }
 75:     
 76:     private function _userModel() {
 77:         return ClassRegistry::init($this->settings['userModel']);
 78:     }
 79: 
 80:     /**
 81:      * Adaptado de http://www.laughing-buddha.net/php/lib/password
 82:      * @return string
 83:      */
 84:     public static function generateRandomPassword($length = 8) {
 85: 
 86:         // start with a blank password
 87:         $password = "";
 88: 
 89:         // define possible characters - any character in this string can be
 90:         // picked for use in the password, so if you want to put vowels back in
 91:         // or add special characters such as exclamation marks, this is where
 92:         // you should do it
 93:         $possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";
 94: 
 95:         // we refer to the length of $possible a few times, so let's grab it now
 96:         $maxlength = strlen($possible);
 97: 
 98:         // check for length overflow and truncate if necessary
 99:         if ($length > $maxlength) {
100:             $length = $maxlength;
101:         }
102: 
103:         // set up a counter for how many characters are in the password so far
104:         $i = 0;
105: 
106:         // add random characters to $password until $length is reached
107:         while ($i < $length) {
108: 
109:             // pick a random character from the possible ones
110:             $char = substr($possible, mt_rand(0, $maxlength - 1), 1);
111: 
112:             // have we already used this character in $password?
113:             if (!strstr($password, $char)) {
114:                 // no, so it's OK to add it onto the end of whatever we've already got...
115:                 $password .= $char;
116:                 // ... and increase the counter by one
117:                 $i++;
118:             }
119:         }
120: 
121:         // done!
122:         return $password;
123:     }
124: 
125: }
126: 
127: ?>
128: 
API documentation generated by ApiGen 2.8.0