Yii Framework Forum: 100% working site throws errors on production server - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

100% working site throws errors on production server

#1 User is offline   Zefrem23 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 01-November 17

Posted 09 November 2017 - 12:19 PM

Hi folks. My Yii2 site worked perfectly on my local machine, however since I've uploaded it to the production server I'm getting some odd issues.

The problem is that, while I can add a record using the system, I can't delete or even view the record once it's created. The error is 403 "You are not allowed to perform this action."

I was using the below 'access' rules in my SiteController but I still have the issue even when this section is commented out.

'access' => [
   'class' => AccessControl::className(),
   'only' => ['logout', 'signup', 'create', 'edit', 'index'],
   'rules' => [
	   [
	   'actions' => ['show'],
	   'allow' => true,
		   'roles' => ['?'],
		],
		[
			'actions' => ['index', 'logout', 'create', 'edit'],
			'allow' => true,
			'roles' => ['@'],
		],
	],
],


I can see the main "index" of each view fine, but trying to "view", "update" or "delete" is not working. As I said, "add" works, but then when it takes me to the "view" action after adding, I get the 403.

If anyone can help me get to the bottom of this issue I'd really appreciate it.
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,405
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 09 November 2017 - 12:35 PM

from top of my head what I can tell you about your permission error is that your delete, view actions might not be assigned proper roles

// this occurs 
The error is 403 "You are not allowed to perform this action."

//should not you add delete and view in your action whitelist for logged in users like so
'actions' => ['delete', 'view', 'index', 'logout', 'create', 'edit'],
                        'allow' => true,
                        'roles' => ['@'],



as far you namespaces go it really depends how you have you app structured, by looking at the snippet above I assume you are using advanced app structure

backend\models\Regions


it is possible you have your models under common\models\Regions, but this is wild guess I don't know about your app structure what would be nice if you could paste your model code here and the code that is using the model.
0

#3 User is offline   Zefrem23 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 01-November 17

Posted 09 November 2017 - 01:28 PM

View Postalrazi, on 09 November 2017 - 12:35 PM, said:

from top of my head what I can tell you about your permission error is that your delete, view actions might not be assigned proper roles

// this occurs 
The error is 403 "You are not allowed to perform this action."

//should not you add delete and view in your action whitelist for logged in users like so
'actions' => ['delete', 'view', 'index', 'logout', 'create', 'edit'],
                        'allow' => true,
                        'roles' => ['@'],



as far you namespaces go it really depends how you have you app structured, by looking at the snippet above I assume you are using advanced app structure

backend\models\Regions


it is possible you have your models under common\models\Regions, but this is wild guess I don't know about your app structure what would be nice if you could paste your model code here and the code that is using the model.


The issue wasn't a namespace one, it was case-sensitivity as you no doubt would've seen right away if I'd pasted my model code. I was referring to backend\Models\Regions instead of backend\models\Regions. Windows tolerated it but Linux wasn't so lenient :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users