Giter VIP home page Giter VIP logo

users's Introduction

CakeDC Users Plugin

Build Status Coverage Status Downloads Latest Version License

Versions and branches

CakePHP CakeDC Users Plugin Tag Notes
^5.0 14.1 14.next-cake5-dev beta
^4.5 13.0 13.0.1 stable
^5.0 12.0 12.0 beta
^4.3 11.0 11.1.0 stable
^4.0 9.0 9.0.5 stable
^3.7 <4.0 8.5 8.5.1 stable
^3.7 <4.0 develop - unstable
3.6 8.1 8.1.0 stable
3.5 6.x 6.0.1 stable
3.4 5.x 5.2.0 stable
>=3.2.9 <3.4.0 4.x 4.2.1 stable
^2.10 2.x 2.2.0 stable

The Users plugin covers the following features:

  • User registration
  • Login/logout
  • Social login (Facebook, Twitter, Instagram, Google, Linkedin, etc)
  • Simple RBAC via https://github.com/CakeDC/auth
  • Remember me (Cookie) via https://github.com/CakeDC/auth
  • Manage user's profile
  • Admin management
  • One-Time Password for Two-Factor Authentication
  • Webauthn for Two-Factor Authentication (Yubico Key compatible)

The plugin is here to provide users related features following 2 approaches:

  • Quick drop-in working solution for users login/registration. Get users working in 5 minutes.
  • Extensible solution for a bigger/custom application. You'll be able to extend:
    • UsersAuth Component
    • Use your own UsersTable
    • Use your own Controller

On the previous versions of the plugin, extensibility was an issue, and one of the main objectives of the 3.0 rewrite is to guarantee all the pieces could be extended/reused as easily.

Another decision made was limiting the plugin dependencies on other packages as much as possible.

Requirements

  • CakePHP 5.0+
  • PHP 8.1+

Documentation

For documentation, as well as tutorials, see the Docs directory of this repository.

Support

For bugs and feature requests, please use the issues section of this repository.

Commercial support is also available, contact us for more information.

Contributing

This repository follows the CakeDC Plugin Standard. If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our Contribution Guidelines for detailed instructions.

License

Copyright 2019 Cake Development Corporation (CakeDC). All rights reserved.

Licensed under the MIT License. Redistributions of the source code included in this repository must retain the copyright notice found in each file.

users's People

Contributors

ajibarra avatar andrej-griniuk avatar andretefras avatar anvyst avatar arodu avatar arusinowski avatar cakedcteam avatar challgren avatar chokri avatar digitalfotografen avatar flohc avatar flohdez avatar half2me avatar josegonzalez avatar jtraulle avatar liviakuenzli avatar lordsimal avatar lorenzo avatar maxime-vacossin avatar meotimdihia avatar neojoda avatar predominant avatar ravage84 avatar rochamarcelo avatar shama avatar skie avatar steinkel avatar stephenburgess8 avatar xymanek avatar yeliparra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

users's Issues

Update documentation on extending the controller

When extending the controller, the model class does not get initialized correctly in the new controller. The easiest way I have found to fix it is to declare the controller like this

<?php

App::uses('UsersController', 'Users.Controller');
App::import('Model', 'Users.User');

class AppUsersController extends UsersController {

then everything works correctly.

PHP 5.3, Cake PHP 2.1.2, MySQL

User model _findSearch $by?

if (!empty($query['by'])) {
$by = $query['by'];
}

if (empty($query['search'])) {
$query['search'] = '';
}

$db =& ConnectionManager::getDataSource($this->useDbConfig);
$by = $query['by'];

no logic in $by

UNIQUE_PROFILE_PROPERTY index breaks installation, if database uses UTF16 collation

Somehow my local DB was set up to use UTF16_* collation by default.

Since cake shell add indexes upon table creation, I was constantly getting:

user_details: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified
key was too long; max key length is 767 bytes

After some debuging I found out, that changing collation for user_details. user_id and user_details. field to UTF8_* and manually adding index, problem solved.

My question - since such issues i not visible form standard cake shell output, might be on plugin or even CP level there could be some checks, wherever none of multi-column indexes are not being created on UTF16 DB/tables/columns, or even force column encoding to something less space consuming when UTF16 :)

Thanks.

Randomly Notice (8): Array to string conversion - parseCriteria on admin_index action

I got this randomly notice on admin_index, got the develop branch for cake 2.3 and last version of search plugin.

Appears on cake 2.3+

I tried all master and develop branch and it still prompts.

Thanks for your reply,

Database Error
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'parseCriteria' at line 1

SQL Query: parseCriteria
Stack Trace
CORE/Cake/Model/Datasource/DboSource.php line 460 โ†’ PDOStatement->execute(array)
CORE/Cake/Model/Datasource/DboSource.php line 426 โ†’ DboSource->_execute(string, array)
CORE/Cake/Model/Datasource/DboSource.php line 670 โ†’ DboSource->execute(string, array, array)
CORE/Cake/Model/Datasource/DboSource.php line 612 โ†’ DboSource->fetchAll(string, array, array)
CORE/Cake/Model/Model.php line 800 โ†’ DboSource->query(string, array, User)
APP/Plugin/Users/Controller/UsersController.php line 341 โ†’ Model->__call(string, array)
APP/Plugin/Users/Controller/UsersController.php line 341 โ†’ User->parseCriteria(array)
[internal function] โ†’ UsersController->admin_index()
CORE/Cake/Controller/Controller.php line 486 โ†’ ReflectionMethod->invokeArgs(UsersController, array)
CORE/Cake/Routing/Dispatcher.php line 187 โ†’ Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 162 โ†’ Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse)
APP/webroot/index.php line 97 โ†’ Dispatcher->dispatch(CakeRequest, CakeResponse)
$this->Prg->commonProcess();
        unset($this->User->validate['username']);
        unset($this->User->validate['email']);

        $this->User->data[$this->modelClass] = $this->passedArgs;

        if ($this->User->Behaviors->attached('Searchable')) {
            $parsedConditions = $this->User->parseCriteria($this->passedArgs);
        } else {
            $parsedConditions = array();
        }

        $this->Paginator->settings['User']['conditions'] = $parsedConditions;
        $this->Paginator->settings['User']['order'] = array($this->modelClass . '.created' => 'desc');

        $this->User->recursive = -1;
        $this->set('users', $this->paginate());

Date deconstruction invalid for non-DDMMYY date formats

UserDetail tries to insert Array as a value because it fails to detect alternative date formats.

Search the UserDetail.php model's saveSection function for this comment:

// Quickfix for date inputs - TODO Try to use $this->deconstruct()?

The following line has the date detection format hardcoded. This is obviously a problem for those who rearrange things. Either a quick loop with in_array or possibly following the TODO in the line would solve the problem and make any related date format possible.

SQL syntax error in extended controller

I'm using a freshly downloaded version of CakePHP (2.2.3), CakeDC Users, Search and Utils plugins.
I installed and set up everything as in documentation and it works.
Then I tried to extend the controller:

<?php
App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {

public function render($view = null, $layout = null) {
    if (is_null($view)) {
        $view = $this->action;
    }
    $viewPath = substr(get_class($this), 0, strlen(get_class($this)) - 10);
    if (!file_exists(APP . 'View' . DS . $viewPath . DS . $view . '.ctp')) {
        $this->plugin = 'Users';
    } else {
        $this->viewPath = $viewPath;
    }
    return parent::render($view, $layout);
}

}

No other methods and no new views.

If I load the URL http://upt/admin/app_users/add the form loads correctly but on submit I get this error:
Notice (8): Array to string conversion [CORE/Cake/Model/Datasource/DboSource.php, line 459] with the following stack trace:

PDOStatement::execute() - [internal], line ??
DboSource::_execute() - CORE/Cake/Model/Datasource/DboSource.php, line 459
DboSource::execute() - CORE/Cake/Model/Datasource/DboSource.php, line 425
DboSource::fetchAll() - CORE/Cake/Model/Datasource/DboSource.php, line 669
DboSource::query() - CORE/Cake/Model/Datasource/DboSource.php, line 611
Model::__call() - CORE/Cake/Model/Model.php, line 784
AppModel::add() - APP/Plugin/Users/Controller/UsersController.php, line 260
UsersController::admin_add() - APP/Plugin/Users/Controller/UsersController.php, line 260
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 485
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 186
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 161
[main] - APP/webroot/index.php, line 92

This produces a SQL syntax error: Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add' at line 1.

If I load http://upt/admin/app_users/edit/AN_EXISTING_UID it doesn't even load the form, just the same error (with edit instead of add).

I tried to duplicate the methods in the child controller (with no code change) and the corresponding views, but nothing changes.

details_controller, Group model

Reported by siran | July 29th, 2011 @ 10:44 PM

is the details feature workin ?

I got: Error: GroupsController could not be found.

And before i got an error on details_controller.php, line 166: $groups = $this->Detail->Group->find('list');, it didn't find Group, and in fact there isn't...

The Sample-Comments-Application uses the Users plugin, but doesn't have the details_controller !

Element Not Found: Elements\Users\sidebar.ctp

I have extended the UsersController as per the instruction on the README file. However, I noticed that putting $this->plugin = 'User' in the render method made the FormHelper::create() build urls with "Users" as the plugin ( I'm pretty sure other helpers would cause a similar issue). So instead I render the views like so:

//app/Controller/AppUsersController.php
public function render($view = null, $layout = null) {
    if (is_null($view)) {
        $view = $this->action;
    }
    $prefix = '';
    if (!file_exists(APP . 'View' . DS . $this->viewPath . DS . $view . '.ctp')) {
        $prefix = 'Users.Users/';
    }
    return parent::render($prefix . $view, $layout);
}

This works great except, since the elements used in the Plugin do not specify the plugin where they reside ( as they normally will not have to since they are used in the same plugin where they reside ), I get a "Element Not Found" error.

So, all that being said, should all calls to elements in the plugin's view be $this->element('Users.Users/sidebar') instead of $this->element('Users/sidebar') ?

cake testsuite Users Controller/UsersController error

Welcome to CakePHP v2.0.4 Console

App : app

Path: /var/www/cakephp/app/

CakePHP Test Shell

PHPUnit 3.6.2 by Sebastian Bergmann.

PHP Fatal error: Call to undefined method PHPUnit_Util_Filter::addFileToFilter() in /usr/share/php/PHPUnit/Framework.php on line 48
PHP Stack trace:
PHP 1. {main}() /var/www/cakephp/lib/Cake/Console/cake.php:0
PHP 2. ShellDispatcher::run() /var/www/cakephp/lib/Cake/Console/cake.php:24
PHP 3. ShellDispatcher->dispatch() /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php:69
PHP 4. Shell->runCommand() /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php:177
PHP 5. TestsuiteShell->main() /var/www/cakephp/lib/Cake/Console/Shell.php:381
PHP 6. TestsuiteShell->_run() /var/www/cakephp/lib/Cake/Console/Command/TestsuiteShell.php:255
PHP 7. CakeTestSuiteCommand->run() /var/www/cakephp/lib/Cake/Console/Command/TestsuiteShell.php:270
PHP 8. CakeTestRunner->doRun() /var/www/cakephp/lib/Cake/TestSuite/CakeTestSuiteCommand.php:110
PHP 9. PHPUnit_TextUI_TestRunner->doRun() /var/www/cakephp/lib/Cake/TestSuite/CakeTestRunner.php:56
PHP 10. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:320
PHP 11. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
PHP 12. CakeTestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
PHP 13. PHPUnit_Framework_TestCase->run() /var/www/cakephp/lib/Cake/TestSuite/CakeTestCase.php:78
PHP 14. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:727
PHP 15. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
PHP 16. CakeTestCase->assertPreConditions() /usr/share/php/PHPUnit/Framework/TestCase.php:779
PHP 17. UsersControllerTestCase->startTest() /var/www/cakephp/lib/Cake/TestSuite/CakeTestCase.php:160
PHP 18. PHPUnit_Framework_TestCase->getMock() /var/www/cakephp/app/Plugin/Users/Test/Case/Controller/UsersControllerTest.php:170
PHP 19. phpunit_mockobject_autoload() /usr/share/php/PHPUnit/Framework/MockObject/Autoload.php:0
PHP 20. require() /usr/share/php/PHPUnit/Framework/MockObject/Autoload.php:107
PHP 21. require_once() /usr/share/php/PHPUnit/Framework/MockObject/Generator.php:46
PHP 22. require_once() /usr/share/php/PHPUnit/Framework/MockObject/Matcher.php:46

Fatal error: Call to undefined method PHPUnit_Util_Filter::addFileToFilter() in /usr/share/php/PHPUnit/Framework.php on line 48

Call Stack:
0.0003 326844 1. {main}() /var/www/cakephp/lib/Cake/Console/cake.php:0
0.0017 422916 2. ShellDispatcher::run() /var/www/cakephp/lib/Cake/Console/cake.php:24
0.0288 1584400 3. ShellDispatcher->dispatch() /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php:69
0.0412 2298304 4. Shell->runCommand() /var/www/cakephp/lib/Cake/Console/ShellDispatcher.php:177
0.0707 3122492 5. TestsuiteShell->main() /var/www/cakephp/lib/Cake/Console/Shell.php:381
0.0713 3123452 6. TestsuiteShell->_run() /var/www/cakephp/lib/Cake/Console/Command/TestsuiteShell.php:255
0.0765 3410916 7. CakeTestSuiteCommand->run() /var/www/cakephp/lib/Cake/Console/Command/TestsuiteShell.php:270
0.1352 6044968 8. CakeTestRunner->doRun() /var/www/cakephp/lib/Cake/TestSuite/CakeTestSuiteCommand.php:110
0.1689 7750584 9. PHPUnit_TextUI_TestRunner->doRun() /var/www/cakephp/lib/Cake/TestSuite/CakeTestRunner.php:56
0.1749 8095060 10. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:320
0.1751 8096376 11. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
0.1751 8096376 12. CakeTestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
0.3414 8105040 13. PHPUnit_Framework_TestCase->run() /var/www/cakephp/lib/Cake/TestSuite/CakeTestCase.php:78
0.3415 8105040 14. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:727
0.3439 8165732 15. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
0.3469 8329732 16. CakeTestCase->assertPreConditions() /usr/share/php/PHPUnit/Framework/TestCase.php:779
0.3469 8329828 17. UsersControllerTestCase->startTest() /var/www/cakephp/lib/Cake/TestSuite/CakeTestCase.php:160
0.3473 8332760 18. PHPUnit_Framework_TestCase->getMock() /var/www/cakephp/app/Plugin/Users/Test/Case/Controller/UsersControllerTest.php:170
0.3473 8333636 19. phpunit_mockobject_autoload() /usr/share/php/PHPUnit/Framework/MockObject/Autoload.php:0
0.3489 8433008 20. require('/usr/share/php/PHPUnit/Framework/MockObject/Generator.php') /usr/share/php/PHPUnit/Framework/MockObject/Autoload.php:107
0.3498 8489544 21. require_once('/usr/share/php/PHPUnit/Framework/MockObject/Matcher.php') /usr/share/php/PHPUnit/Framework/MockObject/Generator.php:46
0.3499 8501676 22. require_once('/usr/share/php/PHPUnit/Framework.php') /usr/share/php/PHPUnit/Framework/MockObject/Matcher.php:46

What to do?

/users/pages/tos

Cake Version: 2.0.4

If including the Plugin like this:

CakePlugin::load('Users', array('routes' => true));

... then the /users/add view renders a link to /users/pages/tos

$tosLink = $this->Html->link(__d('users', 'Terms of Service'), array('controller' => 'pages', 'action' => 'tos'));

I found no way to overwrite the Router
Tried:

Router::connect('/users/pages/tos', array('plugin' => false, 'controller' => 'pages', 'action' => 'display', 'tos')); // this
Router::connect('/users/pages/tos', array('plugin' => 'users', 'controller' => 'pages', 'action' => 'display', 'tos')); // and that

Suggesting this:

$tosLink = $this->Html->link(__d('users', 'Terms of Service'), array('plugin' => false, 'controller' => 'pages', 'action' => 'tos'));

Thanks for this lovely plugin!

$this->loginRedirect

I'm having an issue using the 2.0 version of this plugin. I did not have any issues with th e1.3 version of this plugin.

The issue is that when I put Auth settings in my AppController.php the settings are being ignored. For now I have "hacked it" by commenting out a few lines in:

Plugin/users/Controller/UsersController.php

line 113

//$this->_setupAuth();

line 127 - 151

// public function _setupAuth() {
    //  $this->Auth->allow('add', 'reset', 'verify', 'logout', 'index', 'view', 'reset_password');

    //  if ($this->request->action == 'register') {
    //      $this->Components->disable('Auth');
    //  }

    //  if ($this->request->action == 'login') {
    //      $this->Auth->autoRedirect = false;
    //  }

    //  $this->Auth->authenticate = array(
    //      'Form' => array(
    //          'fields' => array(
    //              'username' => 'email',
    //              'password' => 'password'),
    //          'userModel' => 'Users.User', 
    //          'scope' => array(
    //              'User.active' => 1,
    //              'User.email_verified' => 1)));

    //  $this->Auth->loginRedirect = '/';
    //  $this->Auth->logoutRedirect = '/';
    //  $this->Auth->loginAction = array('admin' => false, 'plugin' => 'users', 'controller' => 'users', 'action' => 'login');
    // }

Now I have added the settings in AppController and the desired effect is occurring.

I know this is not the correct method for which to do this. Traditionally I have put the Auth settings in the beforeFilter of my AppController.php. However this time it is not working. I can live with the hack for now but it would be great if someone could point out what I'm missing.

Thanks!

Various problems

Reported by siran | July 28th, 2011 @ 11:05 PM

app/users/users/login gets redirected to app/users/login, and then it throws the error "Error: LoginController could not be found."

If I create a route like: Router::connect('/users/:action/*', array('plugin' => 'users', 'prefix' => null, 'controller' => 'users', 'action' => 'index'));

Then username&password do not never match, and I never get logged in...

I don't understand why all this is happening

UserDetail

I've installed a fresh copy of the users 2.0 plugin. Most of the application works however, when going to view a user I noticed two things.

  1. When you edit your account, close it the information properly stores in the database table user_details but if you close that and re-open that edit your account page it shows blank.
  2. When viewing an account I get a Noice (8) undefined index : .. for both 'field' and 'value' even though the information is in the database.

View action expecting slug but id passed instead

Reported by Angel S. Moreno | February 9th, 2011 @ 02:06 AM

The plugin's Users Controller's View action is expecting the slug of the user to be the first passed argument but the view in constructing the url in a way that the user id is passed instead.

Stop plugin route after extending plugin

So I have extended the UsersAppController and now the actions are available via the /app_user/* route.

How can I forbid anyone from accessing the plugin's core routes? i.e. /users/*

[Discuss] Search uses exact match

Use case
When searching users using the plugins index view, is it expected behaviour that it should be searching usernames as exacts rather than partials?

Example
Username: davidyell
Search: david
Currently:

WHERE `User`.`username` = 'david'

Expected:

WHERE `User`.`username` LIKE '%david%'

Suggested
I would think that this behaviour is more useful to the user as it will allow less typing and is more likely to always return a result meaning that the user will not feel that they've done something wrong if they get no results.

I think there needs to be a change here, https://github.com/CakeDC/users/blob/master/Model/User.php#L43-45 although I was under the impression that the Search plugin used the LIKE '%foobar%' match as the default?

I'd suggest changing the username field from a 'value' to a 'like'.

If this is a positive change I'll create a PR for it. :)

Error: Undefined class constant 'isAuthorized'

I may have found an issue while upgrading to the latest version.

Fatal Error
Error: Undefined class constant 'isAuthorized'
File: /vagrant/app/Plugin/Users/Controller/UsersAppController.php
Line: 31

I'm using isAuthorized() as a function in my AppController. I receive the above error unless I copy the isAuthorized() function from my AppController in to my AppUsersController.

I'm trying to avoid having redundant functions in multiple places. While investigating I found that in Plugins/Users/Controllers/UsersAppController is calling the parent::isAuthorized as a variable. Prior to upgrading it was calling the parent::isAuthorized(); as a function which in my case will access the function in my AppController.

How does one use the new RememberMe component?

Really chuffed with the new RememberMe component, but struggling to use it. I'm guessing the readme doesn't currently reference it.

I tried adding 'Users.RememberMe' to the $components array in AppController, but then I get this:

Notice (8): Trying to get property of non-object [ROOT/plugins/users/Controller/Component/RememberMeComponent.php, line 81]

Fatal error: Call to a member function loggedIn() on a non-object in /var/www/cmpsr.loc/htdocs/plugins/users/Controller/Component/RememberMeComponent.php on line 91 

It looks like $this->Auth is not being setup before the RememberMe component is running, at least that's my novice CakePHP guess. :-)

Edit details

Reported by riotera | November 11th, 2010 @ 01:43 PM

In DetailsController in 'edit' action:

if (empty($this->data)) {
    $this->data['Detail'] = $this->Detail->getSection($this->Auth->user('id'), $section);
}

corrected:

if (empty($this->data)) {
    $data = $this->Detail->getSection($this->Auth->user('id'), $section);
    $this->data['Detail'] = $data[$section];
}

Documentation

Based on the examples being used this is confusing:

public function beforeFilter() {
parent::beforeFilter();
$this->User = ClassRegistry::init('AppUser');
}

This might be a better example:

public function beforeFilter() {
parent::beforeFilter();
$this->AppUser = ClassRegistry::init('AppUser');
}

Help extending the controller

I'm a little unclear with the documentation on how to extend the controller. Can you help?

(I want to change the Auth->loginRedirect actions.)

Do I create a file called AppUsersController.php

Here:
app/Controller/AppUsersController.php

or Here:
app/Plugin/Users/Controller/AppUsersController.php

And should it look like this to redirect to the Dashboard?

App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {

    $this->Auth->logoutRedirect = '/';
    $this->Auth->loginRedirect = array('controller'=>'users','action'=>'dashboard');

}

'details' naming question

Reported by Ben McClure | September 12th, 2011 @ 12:59 PM

Just starting to check out the Users plugin, and so far I really like what I see.

The first thing that strikes me as odd, however, is the name of the 'details' table.

Wouldn't it be more ideal to name it user_details, both to indicate its actual purpose, and to avoid naming conflicts with any other application or plugin which might have a more generic use for the 'details' table? DetailsController and Detail aren't as big of an issue, because they are at least namespaced inside the plugin, though I still think it would make more sense to go with UserDetailsController and UserDetail for clarity's sake.

I realize it's easy enough to change, but I wasn't sure if there was any particular reasoning behind using such a generic name for such a specific purpose :)

Thanks!

Ben

[2.0] Session got lost after redirect

I run into a situation that I was able to successfully login, but the redirect after the successfull login somehow killed the session.

I had to avoid the redirect and just go manually to the protected pages - then the sessions worked. I figured out that I had to change the Session config in /Config/core.php and use "use_trans_sid" set to true.

Configure::write('Session', array(
    //...,
    'ini' => array('session.use_trans_sid' => true)
));

Did I miss something or is my new session config dangerous?

How work with CakePHP 2.0

First: about readme
ReadMe:
App::uses('Model', 'Users.User');
I think fix it is : App::uses('User', 'Users.Model');


Second: I get error :
Fatal error: Cannot redeclare class User.
When i use a method in AppUsersController (extends UsersController)
$this->User->[find ?]

Call to getSection() on a non-object

Summary: I think the extending controller example in readme should be updated to include

public $uses = array('Users.User');

I'm running into a few problems when extending controller and model on 2.2.x here's solution for one issue.

Create our extending controller following the and also add the render() function example from the readme so we can pickup the existing plugin views.

now access /AppUsers/add and create an account and login at /AppUsers/login , /AppUsers/dashboard loads as well, but /AppUsers/edit results in fatal error

Error: Call to a member function getSection() on a non-object   
File: app/Plugin/Users/Controller/UsersController.php   
Line: 210

to fix add the following to our extending controller

public $uses = array('Users.User');

this will also work

public function beforeFilter() {
  parent::beforeFilter();
  $this->loadModel('Users.User');
}

Help with documentation on extending the controller

Hello all,

I'm still working on getting this plugin going. I'm using cakePHP 2.1.1 and I want to extend the plugin for my application. My previous question about this got me a good answer but I think it's really 1.3 specific.

So the documentation says to 'declare the class' AppUsersController. Please verify that I need to create a AppUsersController.php file and where it should go. Does it go with the rest of the Plugin's controllers or does it sit up with my AppController.php file in the main application?

I've tried both, making sure to put in the following code:
public function beforeFilter() {
parent::beforeFilter();
$this->User = ClassRegistry::init('AppUser');
}

I then try to overwrite the _getMailInstance method from the Plugin's UsersController.php but it doesn't work.

So my questions are:

  1. If I'm extending the controller, I should be able to overwrite methods that exist in the Plugin's UsersController, correct?
  2. Where should I be putting the AppUsersController.php?

Thanks for your time and patience. I really like the Plugin and I'd really like to learn how to utilize it properly.

Al

How work with CakePHP 2.0

First: about readme
ReadMe:
App::uses('Model', 'Users.User');
I think fix it is : App::uses('User', 'Users.Model');


Second: I get error :
Fatal error: Cannot redeclare class User.
When i use a method in AppUsersController (extends UsersController)
$this->User->[find ?]

Sorry , duplicate with issue #21 . Is github bug ?

[notice] Undefined index: COUNT(DISTINCT User.id)

Reported by andrzejborkowski (at gmail) | December 13th, 2010 @ 06:57 AM

Notice (8): Undefined index: COUNT(DISTINCT User.id) [APP/modules/users/models/user.php, line 593]

Debugger::handleError() - CORE/cake/libs/debugger.php, line 306
User::findSearch() - APP/modules/users/models/user.php, line 593
Model::find() - CORE/cake/libs/model/model.php, line 2140
User::paginateCount() - APP/modules/users/models/user.php, line 614
Controller::paginate() - CORE/cake/libs/controller/controller.php, line 1202
UsersController::index() - APP/modules/users/controllers/users_controller.php, line 104
Dispatcher::invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - APP/webroot/index.php, line 84

Poor readme, cant login to page

Reported by andrzejborkowski (at gmail) | January 7th, 2011 @ 07:16 AM
add login to allow action @ users_controller

u must add some information:
u have in view email,password
in code is default cakephp ussername, password, users plugin settings must be sometging like that:

function beforeFilter(){
    $this->Auth->fields = array(
        'username' => 'email', 
        'password' => 'passwd'
        );
}

information about Email component in my case return true but sendmail do not sent mails so i propose to everybody use smtp delivery method

$this->Email->smtpOptions = array(
                'port'=>'465',
                'timeout'=>'30',
                'host'=>'ssl://smtp.gmail.com',
                'username'=>'[email protected]',
                'password'=>'xxx'
                );
            $this->Email->delivery = 'smtp';

add echo $this->Session->flash('auth'); to login view
after that and created && activated account i still cant login to my page ...
how can i debug it and resolve thath problem

when extending render()

you should fix 2.0 version of your readme

controller extend. function render()

replace this:

public function render($action = null, $layout = null, $file = null) {
if (is_null($action)) {
$action = $this->action;
}
if (!file_exists(VIEWS . $this->viewPath . DS . $action . '.ctp')) {
$file = App::pluginPath('users') . 'views' . DS . 'users' . DS . $action . '.ctp';
}
return parent::render($action, $layout, $file);
}

with this:

public function render($action = null, $layout = null, $file = null) {
if (is_null($action)) {
$action = $this->action;
}
if (!file_exists(APP.DS.'View'. $this->viewPath . DS . $action . '.ctp')) {
$file = App::pluginPath('Users') . 'View' . DS . 'Users' . DS . $action . '.ctp';
}
return parent::render($action, $layout, $file);
}

'Remember me' checkbox not working?

With CakePHP 1.3, I have some problems with the "remember me" checkbox on the login form. It basically does nothing. Checked or not, the user has to re-login on the website often.

I checked the code and saw that a cookie was created on login but it's pretty much it.

Am I missing something here? :)

+99 years in setCookie of RememberMe will fail on 32bit PHP

Issue:
The setCookie method of the RememberMe component has a hard coded expire of "+99 years". This will eventually reach strtotime in the _expire method of the Cookie component, and such a far out date will return false on 32-bit PHP (see strtotime notes), effectively turning the remember me cooking into session only.

Here is some discussion of the strtotime 32bit issue on SO: http://stackoverflow.com/questions/3266077/php-strtotime-is-returning-false-for-a-future-date

Possible fix:
Take out the hard code and just rely on component settings for the cookie timeout.

Redirecting with extra leading slash

It seems that if I hit an admin url, such as /admin/articles, I get directed to //users/users/login.

Which is great, but I'm not sure why there is an extra slash in there.

`return_to` named parameter and Apache

In many Apache configurations (since this is the default value), Apache will refuse any request which contains a URL encoded forward slash in the path component of a URL (see AllowEncodedSlashes Directive).

Given this limitation, it is pretty much impossible to use the return_to named parameter on the above configuration. I realise that you can achieve almost the same result using Auth.redirect session variable, but sessions time out and this can cause confusion to end users. I also realise that the controller can be overridden, but if the functionality is there, it makes sense that it be compatible with most configurations.

I propose that in addition to checking for the return_to named parameter (for backwards compatibility), a query string parameter should also be checked. Perhaps someone else has a better solution.

This is just a suggestion. Maybe no one else has ever had this issue in which case it wouldn't make sense to add this given this is a limitation on a specific setup (albeit a common setup).

Authentication issues when getting user data from cookie

The following text is copied from #81 because this should be a separate issue and does not belong into the pull request:

Having made this change, I have another issue. I delete my session cookies, leaving the Users[rememberMe] cookie, and then try to access a restricted method. The $this->Auth->login($data); in AppController returns true, I am logged in, and I can access controller methods which are not visible to anonymous users. However, debug($this->Auth->user('id')); shows null.

I'm not familiar enough with cakephp to know what's going on. I do know that after a form based login, $this->Auth->user('id') returns the currently logged in user's id. So something appears to be different between a cookie based login and a form login.

Issue when saving data in UserDetails Controller

That's what i get with a fresh install. (CakePHP 2.2)

Data is correctly save but on the other side, inputs still blank.
I saw Burzum's patch on this issue but it doesn't work.

Also could you be more explicit about validation on the UserDetail Model, for example i can't get a rule like "notEmpty" working on the firstname input. Maybe this issue is linked to the first one.

Thanks for your reply

Unique on edits

Reported by johnr | August 5th, 2011 @ 03:15 PM

Hello,

If, as a user, I edit my profile it allows me to edit my username to one of an existing user?

Sorry, new to CakePHP, might be something I am doing...

Thanks
John

Unknown User model function 'validator'

I downloaded the master and found that the admin_index is calling a function that doesn't exist:

        $this->User->validator()->remove('username');
        $this->User->validator()->remove('email');

Everything works OK (except the missing () in isAuthorized, already fixed)

PHP 5.3, Cake PHP 2.1.2, MySQL.

Note: I just found that validator is a new function in CakePHP 2.2. So I just commented it out.

Email doesn't work

I'm positive this isn't a problem with your plugin but with my understanding of the new CakeEmail component and Cakephp 2.1.1, but hopefully you could give me a clue.

I've got a fresh cakephp 2.1.1 installation and your plugin installed. I can add users and view them etc. When I go to do anything that handles email I get an Internal Error. The sendVerificationEmail array appears to be empty if that matters.

The only thing I've done to the cake installation that's not in your plugin instructions is to rename email.php.default to email.php and put in my institutions smtp relay information (under $smtp). All plugins are set to load in bootstrap.php.

Any suggestions?

readme fix

hi
i wanted to use the schema tool to create the user tables in mysql but i got errors.

it succeded only when i used this line.
cake schema create --name users --plugin Users

notice the capitale U in "--plugin Users"
whitout it its not working.

also it works only when you type the command when your location is in the app dir. any other location will not work.

thats all,
thanks for the plugin
Tal

Cannot load "schema.php"

When trying to start (branch 2.0 on cakephp 2.2) create schema I got "cannot load schema.php" message, and the same with Migrations
Any hint ?
Fred

Various Notes for Newbies or those with questions

I'm testing each function in this application because I'm going to be using it in an project. I thought I would point out a few of my findings. Community members, please correct my usage if I miss-speak. My intention is to help someone who has run into similar issues.

Users Controller

_sendPasswordReset (line 593)

Change
'from' => 'noreply@' . env('HTTP_HOST'),
To
'from' => Configure::read('App.defaultEmail'),

Email template

I ran into an issue using the default email password reset template. I have copied all of the email templates to /app/View/Plugin/users/Emails/.

If you are using the routes from the readme you will need to:

Change
echo Router::url(array('admin' => false, 'plugin' => 'users', 'controller' => 'users', 'action' => 'reset_password', $token), true);
To
echo Router::url(array('controller' => 'users', 'action' => 'reset_password', $token), true);
Or

Simply customize the templates to your liking.

Readme Notes

Extending the model

This
App::uses('User', 'Users.Model');
class AppUser extends User {
    public $useTable = 'users';
}

Should Be This
App::import('Model', 'Users.User');
class AppUser extends User {
    public $useTable = 'users';
    public $alias = 'User';

Changing login redirect and other _setupAuth() stuff

I created a AppUsersController.php with the following:

App::uses('UsersController', 'Users.Controller');
class AppUsersController extends UsersController {
  public $name = 'Users';

  public function __construct($request = null, $response = null) {
    parent::__construct($request, $response);
    $this->User = ClassRegistry::init('AppUser');
  }

  public function beforeFilter() {
    parent::beforeFilter();
    
  }

  public function _setupAuth() {
    parent::_setupAuth();

    $this->Auth->autoRedirect = false;
    $this->Auth->loginRedirect = '/admin/users/users';
    $this->Auth->loginRedirect = '/login';

  }

Please note that I am inheriting the model a little different than the docs suggest by doing this:

$this->User = ClassRegistry::init('AppUser');

Then added the following to my routes:

  //Used to extend the users controller
  Router::connect('/users', array('plugin' => null, 'controller' => 'AppUsers'));
  Router::connect('/users/:action/*', array('plugin' => null, 'controller' => 'AppUsers', 'action' => 'index'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.