Giter Club home page Giter Club logo

cakephp-user-tools's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cakephp-user-tools's Issues

Not sending emails

I am having issues using the register function, i am not getting the validation email.

Checking the file "src/Model/Behavior/UserBehavior.php", in the function "public function sendEmail($options = [])", i think its missing a line like "return $Email->send();".

The emails are send from this function? or is there any other?

Validation issue in request_password

Hi,

On request_password site(Reset Password link form the Login page) the email validation rules are aborting to send the password reset email with the error message: "The email is already in use."

how to catch events?

I cant understand why you can't catch the event in the controller event manager but in the global yes.

  public function initialize()
  {
    parent::initialize();
    $this->loadComponent('Burzum/UserTools.UserTool');

    EventManager::instance()->on('User.beforeLogin', function ($event) {
      $event->stopPropagation();
      return false;
      // WORKS!
    });

    $this->eventManager()->on('User.beforeLogin', function ($event) {
      $event->stopPropagation();
      return false;
      // DOESN'T WORK
    });

  }

thanks

won't update last activity

This method doesn't do anything.

public function updateLastActivity($userId = null, $field = 'last_action', $options = []) {
        $options = Hash::merge($this->_config['updateLastActivity'], $options);
        if ($this->_table->exists([$this->_table->alias() . '.' . $this->_table->primaryKey()])) {
            return $this->_table->updateAll(
                [$field => date($options['dateFormat'])],
                [$this->_table->primaryKey() => $userId]
            );
        }
        return false;
    }

This is the reason.
$this->_table->exists([$this->_table->alias() . '.' . $this->_table->primaryKey()])

actionMap error

I think that I cannot map actions from xxxxxx.com/users/request_password to action request_password, it goes to action requestPassword instead. With that the action map doesn't seem to work. if I change the action map it works.
Am I doing something wrong ?

Something wrong in quick start tutorial?

Hi Burzum,

When following the quick start tutorial, I get a fatal error upon loading users/register: "Error: Call to a member function user() on a non-object ". The line that causes the problem is $this->set('userData', $this->Auth->user());

This a on a fresh CakePHP install, following your documentation, with UserTools RC5 (selected by using your suggested composer requirement).

What am I doing wrong?

Error: Call to a member function user() on boolean

I've followed your instructions (I'm just learning cake) to the letter and when I go to /users/register or infact, anything with /users/ I get the following error:

Error: Call to a member function user() on boolean
File /my/home/dir/src/Controller/UsersController.php
Line: 16

Any ideas?

Advice on configuration

Hey, I'd like your advice on how to configure it in a case where:
1 - users are only created by an admin
2 - users will access for the first time with the token
3 - users have to create a password on the first access

I'll also try to integrate tinyauth, will it be a problem if I replace role by role_id and create a separate role table like tinyauth advises ?

Thanks

Issues encountered during setup

https://github.com/burzum/cakephp-user-tools/blob/master/docs/Tutorials/Quick-Start.md
Refers to \App\Controller\UsersController but this should be \App\src\Controller\UsersController.php
There is also a syntax error on the first code sample on this page - should be } not );

After installation, I get these errors:
Notice (8): Undefined index: userData [ROOT/vendor/burzum/cakephp-user-tools/src/View/Helper/AuthHelper.php, line 60]
Notice (8): Undefined index: userData [ROOT/vendor/burzum/cakephp-user-tools/src/View/Helper/AuthHelper.php, line 67]

Register error: Undefined variable: userEntity

the line 518 in /src/Controller/Component/UserToolComponent.php will not be executed in the case I submitted unsuccessful request because it will return from the line 515, this cause error with userEntity is undefined.

debugKit conflict

after installing user-tools, debugKit shows a strange behavior lacking some (or all) view variables (path, cake, app, plugins, params and content) but only when loading user-related pages. no problems in other cases.
any hint?
thanks

question about prefix routing

Hi,
i have my admin theme created as Plugin
in my AppController i have condition when prefix is admin use the admin theme. So far all good.

but when i access the admin part i see exception
Missing Template
Cake\View\Exception\MissingTemplateException

Confirm you have created the file: "Admin/Users/UserTools/login.ctp" in one of the following paths:
/var/www/myapp/src/Template/Admin/Users/UserTools/login.ctp

but my theme is in /var/www/myapp/plugins/Admin/src/

do you have any documentation or tutorial how to set up this plugin with route prefix ?

Call to a member function subject() on a non-object

Hi!

I'm trying to make a basic example with UserTools. I deployed a fresh CakePHP 3.0.

php composer.phar create-project --prefer-dist -s dev cakephp/app app

Then I installed UserTools as described in Installation.md:

php ../composer.phar require burzum/cakephp-user-tools:dev-develop

I used Migrations plugin to create the table:

bin/cake Migrations.migrations migrate -p UserTools

To make it work, I had to change two lines in /config/Migrations/20140902003044_initial.php:

  • Commented line 22 ->addColumn('id', 'char'..., because Migrations complained like [PDOException] SQLSTATE[42S21]: Column already exists: 1060: Duplicate column name 'id'
  • deleted 'unique' => true in line 23, because Migrations complained like [RuntimeException] 'unique' is not a valid column option.

Then I created the following controller:

<?php

namespace App\Controller;

class UsersController extends AppController {
    public $components = array(
        'Burzum/UserTools.UserTool'
    );
} 

Note that Installation.md does not suggest the "Burzum/" part.

Anyway, when I test the controller, I get 2 warnings and 1 error:

Strict (2048): Declaration of Burzum\UserTools\Controller\Component\UserToolComponent::initialize() should be compatible with Cake\Controller\Component::initialize(array $config) [ROOT/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php, line 604]

Warning (4096): Argument 1 passed to Burzum\UserTools\Controller\Component\UserToolComponent::initialize() must be an instance of Cake\Event\Event, array given, called in /path/to/cakephp-app/vendor/cakephp/cakephp/src/Controller/Component.php on line 108 and defined [ROOT/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php, line 228]

Error: Call to a member function subject() on a non-object  
File  /path/to/cakephp-app/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php  
Line: 229

Any idea about what is failing or what I'm doing wrong?

$ php -v
PHP 5.5.18 (cli) (built: Oct 28 2014 22:41:49)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Thank you!

Setup Help

I am following your code and am a little confused. I have a default cakephp instal and would like to use your plugin. Right now I would like to use the sql as defined as it will work perfect. How do I set this up the best? Do I need a users controller and model?

Also reading through your UserToolComponent.php I see you defined the emails like below.

'reset_password' => [
    'method' => 'resetPassword',
    'view' => 'UserTools.UserTools/reset_password',
],
'request_password' => [
    'method' => 'requestPassword',
    'view' => 'UserTools.UserTools/request_password',
],
'verify_email' => [
    'method' => 'verifyEmailToken',
    'view' => 'UserTools.UserTools/verify_email',
],

But in the package I see new_password.ctp , password_reset.ctp and verification_email.cp.

Password reset not working

I try to reset the password. Received the email with the following link, when clicked error.

/users/verify/ikfzve7rhysbj5q3m018a4lgdwcpo62n

Action not found. I search the code, it's seems like the correct action is reset_password. When I change to reset_password, still received error coz token is null.

Weird redirects

Something with Auth and the plugin is not working completely fine.
When I try to go to /users/register I get a redirect to login, even if the user is authenticated. I'm using TinyAuth and CakePHP 3.1.8

Whenever I try to access /users/register I get a redirect to login (which should redirect to something else as I'm already logged in)
Whenever I try to access /users/logout I get redirected to the home of the project withou being logged out.

request_password, change_password and login work
register and logout dont

component configuration :

Configure::write('UserTools.Behavior', [
    'useUuid' => false,
    'register' => [
        'verificationExpirationTime' => '+3 days',
    ]

]);

Configure::write('UserTools.Component', [
    'actionMap' => [
        'index' => [
            'method' => 'listing',
            'view' => 'index',
        ],
        'register' => [
            'method' => 'register',
            'view' => 'register'
        ],
        'changePassword' => [
            'method' => 'changePassword',
            'view' => 'change_password'
        ],
        'login' => [
            'method' => 'login',
            'view' => 'login',
        ],
        'requestPassword' => [
            'method' => 'requestPassword',
            'view' => 'request_password',
        ],
    ],
]);

Plugin::load('Burzum/UserTools');

Inside the UserController.

   public function initialize() {
        parent::initialize();
        $this->loadComponent('Burzum/UserTools.UserTool');
        $this->loadComponent('RequestHandler');
    }
  public function beforeRender(Event $event) {
        $this->set('userData', $this->Auth->user());
    }

   public function register() {}
   public function change_password() {}
   public function logout() {}
   public function login() {}

AppController

$this->loadComponent('Auth', [
            'authenticate' => [
                'Form' => [
                    'fields' => ['username' => 'email', 'password' => 'password']
                ]
            ],
            'authError' => 'Did you really think you are allowed to see that?',
            'authorize' => [
                'TinyAuth.Tiny' => [
                    'multiRole' => false
                ]
            ],
            'unauthorizedRedirect' => false
        ]);

This is the acl file for tiny auth, I have been trying everything

[Users]
*, index, view, register, logout = admin ; Only user role can access index action
changePassword, logout, login, register = * ;
register = admin

[UserTools.UserTools]
* = admin

[UserTools]
* = admin

Using controller instead of component

Hi @burzum
While I am using the plugin I thought about the idea of using a controller instead of component, that may because:

  • The code will be more clear short and may more performance.
  • The controller can be override a little more easily.
  • The component is useful when we use its functions in multi places but here we just need it for our UsersController.

I you liked the idea I may help by a PR about this.

Login not possible after register

Installed cakephp-user-tools on a brand new cakephp application v3.6.10 without any other dependencies. Installed it with your documentation.

Loaded the plugin in /conf/bootstrap.php with

Plugin::load('Burzum/UserTools');

Activated the plugin in AppController.php with

$this->loadComponent('Auth');
$this->loadComponent('Burzum/UserTools.UserTool');

$this->Auth->allow([
    'login', 'register', 'add', 'display'
]);

public function beforeRender(Event $event) {
    $this->set('userData', $this->Auth->user());
}

These functions work:

  • Register
  • Activation Email
  • Reset Password - Enter email
  • Reset Password - Receive email
  • Reset Password - Set new password

This function does not work:

  • Login

After opening the link in the activation email, I get logged in. But when I log out and try to log in again, it just says Invalid login credentials.

I don't know what to debug, I don't know where to debug. I tried to debug some of the processes in the UserToolsComponent.php but it's just too big.

Maybe a problem with the newest cake version?

Update

Found out that I mustn't load the AuthComponent in AppController.php.

User tools behaviour config email

I have problem with setting up email.
I used in my bootstrap:

Configure::write('UserTools.Behavior', [
    'emailConfig' => 'mailhog'
]);

my email settings in config/app.php are:

'EmailTransport' => [
        'default' => [
            'className' => 'Cake\Mailer\Transport\MailTransport',
            /*
             * The following keys are used in SMTP transports:
             */
            'host' => 'localhost',
            'port' => 25,
            'timeout' => 30,
            'username' => null,
            'password' => null,
            'client' => null,
            'tls' => null,
            'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
        ],
        'mailhog' => [
            # These are default settings for the MailHog container - make sure it's running first
            'className' => 'Smtp',
            'host' => 'myapp-mailhog',
            'port' => 1025,
            'timeout' => 30,
        ],
    ],

/**
     * Email delivery profiles
     */
    'Email' => [
        'default' => [
            'transport' => 'default',
            'from' => '[email protected]',
            'charset' => 'utf-8',
            'headerCharset' => 'utf-8',
        ],
        'mailhog' => [
            'transport' => 'mailhog',
            'from' => '[email protected]',
            'charset' => 'utf-8',
            'headerCharset' => 'utf-8',
        ]
    ],

when i use user registration form it ends with Cake Exception

Could not send email: unknown
Cake\Network\Exception\SocketException

however when i change in my email delivery in default profile the "transport" from "default" to "mailhog" all works fine.

it seems that the behavior config

Configure::write('UserTools.Behavior', [
    'emailConfig' => 'mailhog'
]);

is ignored an using always default profile.

Or am i doing something wrong with the UserTools.Behaviour config ?

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.