amnah / yii2-user

Yii2 user authentication module
MIT License
253 stars 104 forks source link

Undefined class constant 'STATUS_INACTIVE' #179

Open larry-tx opened 7 years ago

larry-tx commented 7 years ago

I just installed your module and attempted to log in with the neo/neo credentials. It returned a Fatal PHP error: Undefined class constant 'STATUS_INACTIVE'. See attached image of the complete error message. status_inactive

I could probably figure out how to make it work, but I thought you might want to fix it so someone else doesn't run into the same error. If I've done anything wrong, please don't hesitate to let me know.

larry-tx commented 7 years ago

Actually, it gets worse. When I try to go to /user/admin or /use/account, I get an Object not found message: image

My common/config/main.php looks like this:

<?php

    use kartik\datecontrol\Module;

    return [
        'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
        'components' => [
            'user'  => [
                'class' => 'amnah\yii2\user\components\User',
            ],
            'cache' => [
                'class' => 'yii\caching\FileCache',
            ],
        ],
        'modules'    => [
            'user'        => [
                'class' => 'amnah\yii2\user\Module',
                // set custom module properties here ...
            ],
            'datecontrol' => [
                'class'              => 'kartik\datecontrol\Module',

                // format settings for displaying each date attribute (ICU format example)
                'displaySettings'    => [
                    Module::FORMAT_DATE     => 'php:m/d/Y',
                    Module::FORMAT_TIME     => 'php:h:i A',

As you can see, I haven't tried to do anything other than simply copy your directions. Any help you can give on this would be most appreciated.

amnah commented 7 years ago

Did you update the configuration for the frontend and the backend? These two config files will overwrite what you have in the common config.

Edit: wrong

amnah commented 7 years ago

Woops I think that previous comment is wrong. What you probably need to do is update the common/models/User.php file completely.

It would need to extend my User class, like so:

<?php

namespace common\models;

use Yii;
use amnah\yii2\user\models\User as BaseUser;

class User extends BaseUser
{
}
larry-tx commented 7 years ago

I tried several things, none of which worked:

  1. I tried having the component and module config in common/config/main.php with the User class modified as you have it below. /user/admin and /user/account still give an Object not found error.

  2. Then, I tried making the component and module config in the backend/config/main.php and frontend/confic/main.php and adding the modified User class to both apps. That still gave me an Object not found on any /user/… URL.

From: amnah [mailto:notifications@github.com] Sent: Tuesday, December 27, 2016 5:46 AM To: amnah/yii2-user yii2-user@noreply.github.com Cc: LarryTX LarryTX@outlook.com; Author author@noreply.github.com Subject: Re: [amnah/yii2-user] Undefined class constant 'STATUS_INACTIVE' (#179)

Woops I think that previous comment is wrong. What you probably need to do is update the common/models/User.php https://github.com/yiisoft/yii2-app-advanced/blob/master/common/models/User.php file completely.

It would need to extend my User class, like so:

<?php

namespace app\models;

use Yii; use amnah\yii2\user\models\User as BaseUser;

class User extends BaseUser { }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amnah/yii2-user/issues/179#issuecomment-269315490 , or mute the thread https://github.com/notifications/unsubscribe-auth/AABRB1I70qVdYm8KmWY0kgu041w_9pTeks5rMPp9gaJpZM4LWEy2 .

amnah commented 7 years ago

Wait, how did you log in the first time - what was the url?

Did you set up pretty urls?

larry-tx commented 7 years ago

Actually, I remembered that I logged in through the frontend before I installed your extension, so it was the advanced template that Yiii2 installs. I did set up pretty URLs.

Date: Tue, 27 Dec 2016 09:01:06 -0800 From: notifications@github.com To: yii2-user@noreply.github.com CC: LarryTX@outlook.com; author@noreply.github.com Subject: Re: [amnah/yii2-user] Undefined class constant 'STATUS_INACTIVE' (#179)

Wait, how did you log in the first time - what was the url?

Did you set up pretty urls?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

amnah commented 7 years ago

i dont think your pretty urls is working. did you set up pretty urls properly?

http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-apache-configuration

your error is an apache error, it's not even getting into php yet so it has nothing to do with yii2 or my module

larry-tx commented 7 years ago

I will research the error in the Apache logs. I'm pretty sure that I set up pretty URLs correctly. First, this is about the 500th time that I've set up a Yii2 site, and they've worked every other time. More importantly, this site currently has about 15 models with associated CRUD. Before I installed your extension, the pretty URLs were working for every single one of those. I usually don't do much in the way of security until after a site is virtually ready to go.

Date: Tue, 27 Dec 2016 11:23:28 -0800 From: notifications@github.com To: yii2-user@noreply.github.com CC: LarryTX@outlook.com; author@noreply.github.com Subject: Re: [amnah/yii2-user] Undefined class constant 'STATUS_INACTIVE' (#179)

i dont think your pretty urls is working. did you set up pretty urls properly?

http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-apache-configuration

your error is an apache error, it's not even getting into php yet so it has nothing to do with yii2 or my module

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

amnah commented 7 years ago

Hmmm ok that's weird then. Ok, assuming that your pretty urls are working, let's take a step back.

Did you update your nav links to point to the new urls?

It should look something like this

$menuItems[] = ['label' => 'Signup', 'url' => ['/user/register']];
$menuItems[] = ['label' => 'Login', 'url' => ['/user/login']];

After that's done, go to your site and check the urls. What's the exact url that it generated? Copy/paste that here please.

Then click the link and try to go to the page. Does the page load successfully?

larry-tx commented 7 years ago

Actually, I never bother with the nav links. I type the URL directly in the address bar. When it doesn't work, I retype it several times to make sure.

Date: Tue, 27 Dec 2016 12:37:37 -0800 From: notifications@github.com To: yii2-user@noreply.github.com CC: LarryTX@outlook.com; author@noreply.github.com Subject: Re: [amnah/yii2-user] Undefined class constant 'STATUS_INACTIVE' (#179)

Hmmm ok that's weird then. Ok, assuming that your pretty urls are working, let's take a step back.

Did you update your nav links to point to the new urls?

It should look something like this

$menuItems[] = ['label' => 'Signup', 'url' => ['/user/register']]; $menuItems[] = ['label' => 'Login', 'url' => ['/user/login']]; After that's done, go to your site and check the urls. What's the exact url that it generated? Copy/paste that here please.

Then click the link and try to go to the page. Does the page load successfully?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

parvvee commented 6 years ago

@LarryTX fix for the issue in yii2-advanced is in your config/main.php you need to remove "user" array item from component from backend / frontend and you shall have this workling.Thank you

mydesign commented 6 years ago

User's module may be connected on /common comment it in backend and frontend