Page 1 of 1

Deleted admin privileges

Posted: Thu Oct 20, 2016 11:14 pm
by 64057
hello everyone

i just deleted admin privileges by mistake on opencart panel. and whenever i log in admin on panelit just shows dashboard. nothing else.
so checked phpmyadmin oc_user group and oc user and its looking as it would be.
so i think i have to do something on ftp please someone! illuminate me

Re: Deleted admin privileges

Posted: Fri Oct 21, 2016 11:26 pm
by Johnathan
Log in using FTP, and then make this edit:

Code: Select all

IN:
/system/library/user.php OR /system/library/cart/user.php

AFTER:
public function hasPermission($key, $value) {

ADD:
return true; 
That will enable all areas for all users, so you can then go to your admin panel and re-save the permissions in Users > User Groups. Don't forget to remove the edit after you've done that, or permissions will not be checked at all.

Re: Deleted admin privileges

Posted: Mon Jul 10, 2017 5:30 am
by frishops
Hey, thanks a lot. this just helped me!

Re: Deleted admin privileges

Posted: Tue Oct 10, 2017 10:38 am
by myanno
i can't solved my problem , please help

Re: Deleted admin privileges

Posted: Tue Oct 10, 2017 10:36 pm
by Johnathan
Is this related to admin permissions? If so, you need to follow the steps I've outlined above. If you can't, then you should ask someone you know who could do it for you, or hire someone to fix the issue.

If this isn't related to admin permissions, then post a new topic.

Re: Deleted admin privileges

Posted: Wed Oct 18, 2017 11:44 pm
by mrblond
Hi,
can you please clarify where exactly to put return true; in the code you specified:

Code: Select all

public function hasPermission($key, $value) {
		if (isset($this->permission[$key])) {
			return in_array($value, $this->permission[$key]);
		} else {
			return false;
		}
	}

Re: Deleted admin privileges

Posted: Wed Oct 18, 2017 11:57 pm
by Johnathan
After this line:

Code: Select all

public function hasPermission($key, $value) {

You add a new line with this code:

Code: Select all

return true; 

Don't forget to remove the line you added after you're able to re-save your permissions.

Re: Deleted admin privileges

Posted: Mon Feb 12, 2018 6:07 pm
by pixelhaus
Hi there,
I'm having a similar issue after a client removed his permissions. I've added the extra line (as shown in the screenshot) to system/library/cart/user.php (v2.3.0.2) but it's not making any difference. Is there anything else I might have missed ?
Image

Re: Deleted admin privileges

Posted: Tue Feb 13, 2018 11:27 pm
by Johnathan
If you have an ocMod that affects that file, the edit won't activate until you refresh your ocMod cache in Extensions > Modifications.

Re: Deleted admin privileges

Posted: Mon Jul 30, 2018 8:37 am
by sameverything
Johnathan wrote:
Wed Oct 18, 2017 11:57 pm
After this line:

Code: Select all

public function hasPermission($key, $value) {

You add a new line with this code:

Code: Select all

return true; 

Don't forget to remove the line you added after you're able to re-save your permissions.
Hi, Thanks for this

I too by accident deleted my admin permissions, I am on OpenCart 3
I added the line on cart/user.php
And now I can Select All permissions, and Save, with no issues, however, it is not really "saved"
Once I revisit the User Group permissions, all the vital permissions are unchecked.
I tried refreshing and clearing mods etc.

Any suggestions?

Thanks
Sam

Re: Deleted admin privileges

Posted: Tue Jul 31, 2018 10:47 pm
by Johnathan
Sounds like you have something more going on, then. I'd suggest uninstalling any mods you have installed (especially ones with ocMod or vQmod files, since those are likely to be the cause) and see if that helps.

If not, you may need to hire someone to take a look for you. If you need to find a developer, you should post a request in the OpenCart "Commercial Support" forum, which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area.

Re: Deleted admin privileges

Posted: Fri Sep 13, 2019 12:19 pm
by Moel
Johnathan wrote:
Wed Oct 18, 2017 11:57 pm
After this line:

Code: Select all

public function hasPermission($key, $value) {

You add a new line with this code:

Code: Select all

return true; 

Don't forget to remove the line you added after you're able to re-save your permissions.
This code helping, but all permission become enable with or without checking the lists. Any suggestion how to make permission can be arrangeable like opencart normally do without error issue?

Re: Deleted admin privileges

Posted: Thu Jan 28, 2021 1:46 am
by SVN
Johnathan wrote:
Tue Jul 31, 2018 10:47 pm
Sounds like you have something more going on, then. I'd suggest uninstalling any mods you have installed (especially ones with ocMod or vQmod files, since those are likely to be the cause) and see if that helps.

If not, you may need to hire someone to take a look for you. If you need to find a developer, you should post a request in the OpenCart "Commercial Support" forum, which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area.
I had the same problem and added the line in USER.PHP, I could login, I cleared the cache from OCMOD and now I get an ERROR500 when I try to go to my admin page. I deleted the link in USER.PHP again but still I get the error when going to www......com/admin. What can I do, I can't login anymore...

Re: Deleted admin privileges

Posted: Thu Jan 28, 2021 1:54 am
by straightlight
I had the same problem and added the line in USER.PHP, I could login, I cleared the cache from OCMOD and now I get an ERROR500 when I try to go to my admin page. I deleted the link in USER.PHP again but still I get the error when going to www......com/admin. What can I do, I can't login anymore...
Error logs.

Re: Deleted admin privileges

Posted: Thu Jan 28, 2021 4:02 pm
by SVN
straightlight wrote:
Thu Jan 28, 2021 1:54 am
I had the same problem and added the line in USER.PHP, I could login, I cleared the cache from OCMOD and now I get an ERROR500 when I try to go to my admin page. I deleted the link in USER.PHP again but still I get the error when going to www......com/admin. What can I do, I can't login anymore...
Error logs.
So my frontpage works normal, only when I go to my admin page I get this error.

Parse error: syntax error, unexpected 'if' (T_IF) in /home/users/system/storage/modification/system/library/cart/user.php on line 73

public function hasPermission($key, $value) {
if (isset($this->permission[$key])) {
return in_array($value, $this->permission[$key]);
} else {
return false;
}


These are te only log lines since yesterday.
2021-01-27 12:07:33 - PHP Notice: Undefined index: product_id in /home/users/catalog/controller/extension/module/ianalytics.php on line 83
2021-01-27 15:39:32 - PHP Notice: Undefined index: custom_h1 in /home/users/vqmod/vqcache/vq2-system_storage_modification_catalog_controller_product_category.php on line 123

Re: Deleted admin privileges

Posted: Thu Jan 28, 2021 6:08 pm
by xxvirusxx
Contact extension/module developer support.

This worked 100% Thansks Johnathan

Posted: Mon Apr 25, 2022 4:50 pm
by lockbox
Johnathan wrote:
Wed Oct 18, 2017 11:57 pm
After this line:

Code: Select all

public function hasPermission($key, $value) {

You add a new line with this code:

Code: Select all

return true; 

Don't forget to remove the line you added after you're able to re-save your permissions.