You don't have permission to view courses here

You don't have permission to view courses here

by Usman Kazi -
Number of replies: 26

Hi 

one of my client admin make changes in the system, after we are unable to access its login page. 

the URL is as follows 

https://lms.pac.edu.pk/login/index.php

kindly let me know how i can resolve this issue 

your prompt response will be highly appreciated 

Regards 

Usman kazi 

Average of ratings: -
In reply to Usman Kazi

Re: You don't have permission to view courses here

by Colin Fraser -
Picture of Documentation writers Picture of Testers
Were the changes made documented? If not, sack him..smile What kind of changes, rewriting core code? Database?
Download the same version of Moodle and extract it, replace any edited pages, or even the entire code base. You should be able to access the Moodle codebase via the server, use Putty to access the code, and delete everything except the config.php file. If that was the file changed, replace it with an older version, you should have one in a backup somewhere.
The database can be accessed using any number of tools, phpMyAdmin for one, see if you can edit the database directly or, replace the database entirely with the last backup prior to any changes.
I know this is a sledgehammer approach, but the reality is that is you try to finesse it, it can take a lot of time, or make things worse, or not achieve anything at all. Best bet, replace everything with the last working backup.
In reply to Usman Kazi

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

What authentication were you using before other admin made changes?

Might be able to get to config by  going directly to:

https://site/admin/settings.php?section=manageauths

you will be prompted to login using above.

Got ssh access to server?

cd /path/to/moodlecode/admin/cli/

php cfg.php |grep auth

shows the active authentication methods.

If yours is missing one can re-activate it (assuming other config details still remain in DB) via config.php by making an entry:

$CFG->auth='manual,email,oauth2,webservice'

Above is example.

php cfg.php |grep login

might show info that could also be changed via config.php

Kinda hard to guess without a little more info.

Might have to do as Colin suggest! :\

'SoS', Ken


Average of ratings: Useful (1)
In reply to Usman Kazi

Re: You don't have permission to view courses here

by Eric Taylor -

Meanwhile… 5 months later I managed to get this error on my dev box jumping around between themes to test out a replacement for the amazing and almost perfect (and now dead) Essential theme so I can jump from 3.6 to 3.8.

I believe it happened after I unchecked "Show courses when not logged in" or something like that in the Setup->Appearance area somewhere. I most definitely did not mess with the database manually or anything like that!

Long story short, the solution is to run purge_caches from the admin/cli/ folder.

/path/to/php /path/to/moodle/admin/cli/purge_caches.php

Hope this helps others because it took me like an hour and a half to stumble across this solution since I couldn't log in to try and troubleshoot…

Average of ratings: Useful (1)
In reply to Eric Taylor

Re: You don't have permission to view courses here

by Libin Sham -

Iam also having same issue, 


Now iam opened a purge_caches.php 
but i dont know how to fix this issue , can u please guide me

In reply to Libin Sham

Re: You don't have permission to view courses here

by Eric Taylor -

You need to run it from the command line. So for Mac that’s launching Terminal app and on Windows it’s Power Shell. 

You have to locate the php.bin for Mac/Linux or php.exe for Windows and then run that and tell to to open the purge_caches.php file and run it. That’s the example I show in my post where I’m saying you type /path/to/php.bin /path/to/purge_caches.php. 

In reply to Eric Taylor

Re: You don't have permission to view courses here

by Libin Sham -

iam also having same issue

Attachment error moodle.jpg
In reply to Libin Sham

Re: You don't have permission to view courses here

by Colin Fraser -
Picture of Documentation writers Picture of Testers
1. Have you followed the procedures outlined above?
2. Add the line Ken suggests
edit config.php
one line above the line that has:
require_once(__DIR__ . '/lib/setup.php');
add this line:
$CFG->defaultfrontpageroleid='8';

3. If that doesn't work, go to the database, via phpMyAdmin look for mdl_role_capabilities table and make sure that the each moodle/site: capability has a context id, role id and permission of 1. Be especially aware of the "goanywhere_doanything" permission, that should only be assigned to role id of 1. This is tedious and exacting, but you should be able to move forward, unless you have managed to delete the Roles themselves. Just be careful. While scrolling through the table, and the site capabilities are not all clumped in one group, just check and make sure that the other capabilities that are set are correct.  

That should get you into the Moodle. 
In reply to Eric Taylor

Re: You don't have permission to view courses here

by Libin Sham -
but iam hosted in live .. how to access in cpanel
In reply to Libin Sham

Re: You don't have permission to view courses here

by Eric Taylor -

No idea. Can you turn on ssh access to the site? You may need someone in tech support at your hosting site to run it from their end if not. 

In reply to Eric Taylor

Re: You don't have permission to view courses here

by Dr. Michael Commini -

After turning on the privacy policy check, we were able to access the site for a bit. After logging out however, we can no longer get to even the front page: https://siresacademy.org

I also followed one of the articles I found on the site that suggested for sites with a lot minors to turn off agree to policies for authenticated users and create a new role, which I did. I went to assign this role to myself as site admin and the managers, teachers and parents but only one manager was in the list. I assigned her the role but even she can't get in.

I don't have SSH capabilities and tried running the purge_caches.php file through cron, to no effect.

I've searched the database via phpMyAdmin but am not sure what settings to adjust. I can see the new role but am not sure how to assign it to myself or anyone else via phpMyAdmin. I also do not see where to reset the privacy policy test to null.

I'm fortunate in that we are still standing the site up and have not finished building it out. Sadly, we don't have a sandbox so everything is done via the web. I did not make a backup prior to adjusting the settings, so restoring an earlier version is not an option.

Can anyone assist? What settings in the db do I need to reset? Your help is much appreciated.

Regards,

MC

In reply to Dr. Michael Commini

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

@Dr. Michael Commini

You probably needed to start a new posting rather than adding to the confusion of this thread ... next time!

Surely you have access to something like cPanel where you can browse files (file manager).   If so navigate to the folder where code for moodle is kept ... possibly /usr/accountname/public_html/

and edit config.php

one line above the line that has:

require_once(__DIR__ . '/lib/setup.php');

on it

add this line:

$CFG->defaultfrontpageroleid='8';

Save the file.  No need to restart any service ... just use browser to see if you can get back into site.

If you do get back in, navigate to where you will working with roles and un-do ... no un-do button so you'll have to re-call what you did.

/admin/roles/manage.php

Good luck!

'SoS', Ken

In reply to Ken Task

Re: You don't have permission to view courses here

by Dr. Michael Commini -
@Ken Task: Hi Ken,

thank you for your suggestion. Unfortunately, it did not work. I am able to get to the cPanel and I am able to FTP in. I cannot, for some reason, access the site via SSH, though I used to be able to. I suspect the hosting provider removed the permission to do so when they "upgraded" their servers and removed many of the services we were contracted for when we first created the account many years ago. Providers, it seems, are not loyal to their long time clients.

Anyway, rant aside, is there anything else you recommend I try? As I said in my original post, I do have access to phpMyAdmin and can make changes directly in the database if need be. I just need to know where to change it. The last thing I want to have to do is uninstall the database and re-install.

Thank you again for whatever assistance you can provide.

Mike
In reply to Dr. Michael Commini

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

What's the date of your last database backup?   mysqldump to .sql file?

Do you have one?  If you don't have one ... SHAME ON YOU!

Might have to use that .sql file imported into a new DB change config.php file for DB info, to get back in again.  That would be the safest way ... yes, would loose what one had done since the data of last SQL dump, but ....

I know that messing with tables ... remember supposed to be relational ... isn't a good idea, but .... will share info ... which you could do / find with your PHPMyAdmin.  

Modify colmuns directly with PHPMyAdmin at your own risk!

In the DB:
mysql> show tables like '%role%';

| mdl_role                         |
| mdl_role_allow_assign            |
| mdl_role_allow_override          |
| mdl_role_allow_switch            |
| mdl_role_allow_view              |
| mdl_role_assignments             |
| mdl_role_capabilities            |
| mdl_role_context_levels          |
| mdl_role_names                   |
| mdl_tool_cohortroles             |
| mdl_tool_dataprivacy_purposerole

In looking at the tables names, the table mdl_role_capabilities - might be what you seek. It has 1325 rows.  but do know 'context' comes into play and that really does make it difficult to 'guess'.

You mentioned dataprivacy .... see there is a table for that.

Have never been in a situation like yours ... so above is just where to look info ... maybe!

Good luck!

Might consider hiring a Moodle Partner for this job.

'SoS', Ken


In reply to Ken Task

Re: You don't have permission to view courses here

by Tim Saville -

Hi ken

I have had the same issue after making some minor changes to the login on the admin page through moodle. Nothing that should of effected my admin login, just checked a few more security measure in the list. I did try your fix via cpanel with no effect so when I try and log back in I get the you don't have permission to access these files notification.

What needs to be changed? either in the files on the server, or is it a permission issue?

Ive attached a copy of the php file from the server with your suggestion at line 26.

Regards Tim

Attachment PHP info.JPG
In reply to Tim Saville

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

@tim Saville

When you piggy back in a forum posting it makes things very confusing and for those who happen along IF they try out something suggested to another user.

First, you shared too much info of your config.php file.
Never share login/pass info!

In official moodle install docs it says to put moodledata in a directory
that is not directly accessible via the web.   In your config.php file, the
hidden .ht5blahblahblah file is in the code folder for moodle.

I can verify that you have 3.9.x code.

The error is a moodle error that says in it's entirety:

You don't have permission to view this list of courses.

That suggest permissions of a user in moodle.

I see in your config.php file, that moodledata ... called .ht5jmytfzmaedz.data has a 'slash' at the end of the path to it.

None of the variables in config.php should have a / at the end.

Getting error 500's here.

IF it is a user/file/folder ownerships issue ...
I see that account you might be using is 'ontrac1'?
Should all files folders in the Training folder belong to that user/group?

See server is running nginx .. have you checked nginx logs ... error logs/ssl logs/ any logs for clues?

'SoS', Ken

In reply to Ken Task

Re: You don't have permission to view courses here

by Tim Saville -

Ken

Thanks firstly for your prompt response, much appreciated. I apologise for the piggy back post, in future Ill log it as a new issue. The config file came from the folder downstream of the root folder.

thetrainingedge.com.au/Training is where the moodle installation was done via auto installer on the cpanel. Had no issue with initial login or logouts for a a week or so until today when I checked a couple of the login boxes on the admin settings in moodle site admin.

I have not changed any files on the server since installation or any other files. I'm using the enlightlite theme and other than that have had no issues. All was a clean install.

I checked with the hosting provider earlier today to see if there was any issues, they have no server issues. They did mention that the index.html file was missing from root folder and or the moodle install folder, the folder where my moodle install is, so maybe this is part of the issue. Though not sure how it would delete that file.

The site files for moodledata,  should it be in a subfolder of Training called Moodledata? Not the other one .ht5jmytfzmaedz.data, or remove the slash?

Is the permission for this folder not allowing access?

Not sure what you mean by server running nginx .. have you checked nginx logs ... error logs/ssl logs/ any logs for clues? this is a bit out of my league.

Otherwise I will need to do a new install and hope for the best.

Regards Tim

In reply to Tim Saville

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

@Tim ... ahhhh, one of those 'one click wonder' installs.

Question about is it permissions ... don't think any change to an admin setting would also change ownerships/permissions to folders and files in code.

In admin of a Moodle, please understand that the moodle interface as an admin level isn't the same as admin of a site using cPanel.  And that sometimes, especially with an issue like this one, you need to locate things like web server (your site runs nginx) logs and be able to view them to see what they might say.  Can do that with cPanel, I think.

'One click wonder' installed the data directory in code folder ... which is not recommended ... but since it worked at one time ... and now doesn't, leave it where it is.   Normally, if an admin did that, an .htaccess file would be placed in the moodledata directory to help protect it.  nginx (your web service) doesn't use .htaccess files so ???? (one click wonder!)

What I suggested to you was to remove the trailing slash in your config.php file for the path to your moodledata.

This part ... 'when I checked a couple of the login boxes on the admin settings in moodle site admin' ... someone would have to be able to do a Vulcan Mind Meld to know exactly.   Do you recall what those settings were?

This is where looking at nginx access logs might provide the url to your site which would give us a clue ... otherwise ... guesses.

Note: your provider saying there was a missing index.html file code code root would really indicated, that person has not a clue ... moodle code as well as any web server app that used php would have index.php default files ... not index.html.

At this stage ... you might have to re-install ... did you have any courses developed or being used?

Think I'd try this first:

Go directly to this url ... you change 'site' below to your URL:

https://site/report/configlog/index.php

That's a form that shows all the config changes to a moodle ... since it does require a login, you will be prompted to login - if you can - it will then forward to that report.

'SoS', Ken

In reply to Ken Task

Re: You don't have permission to view courses here

by Tim Saville -

Ken

Again thanks for your prompt reply and time in helping resolve this issues.

Tried the url https://site/report/configlog/index.php, came back with same error message and no access to login.

I did some looking at the server files and made sure that the files were were they should be. In doing so I found a moodledata folder from a previous install and version 3.6? from about 18 months ago. Even though I uninsntalled this version and the new 3.9 was installed in a totally different domain on the server and sub folder, i was hoping to avoid any conflicts? I have 3 domain name on the server one has Mooddle installed in this http://thetrainingedge.com.au/Training Current 3.9 that has the issue. The other was in http://Ontracc.org/elearning old version uninstalled. The moodledata folder was downline of this domain in its own separate folder. I did look at some error logs of the server and they were all related to login on thetrainingedge.com.au or /Training folder see below for an example.

[Tue Jul 21 14:12:05.093471 2020] [autoindex:error] [pid 6367:tid 47386946766592] [client 49.179.153.129:0] AH01276: Cannot serve directory /home3/ontracc1/public_html/thetrainingedge.com.au/: No matching DirectoryIndex (index.php,index.php5,index.php4,index.php3,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.jp,index.phtml,index.shtml,index.xhtml,index.html,index.htm,index.wml,Default.html,Default.htm,default.html,default.htm,home.html,home.htm,index.js) found, and server-generated directory index forbidden by Options directive

In relation to admin changes on the moodle admin site admin , I made some changes to the self based email registrations and forced logins and that was really all I did.

I have just been doing a set up of the new 3.9 so I don't have anything that needs to be saved of value, just time. But it is helpful to know in case the problem arises again once its an active site

All else fails I'll do a new reinstall, any suggestion regarding this would be appreciated.

Regards Tim

In reply to Tim Saville

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

moodle error says can't view ...
cannotviewcategory

db
table mdl_role_capabilities
capability column
There are 34  rows that have moodle/site:
Table has a time modified column that is epoch time stamp
So if you could get an epoch time stamp value for the approximate time you changed stuff, could narrow down searching mdl_role_capabilities

446 rows that contain 'view' ...

You said: 'self based email registrations and forced logins'

From command line ... code/admin/cli/ there is a cfg.phg script which shows settings ...

Could try something like:

php cfg.php |grep forced

change the term looking for after the word 'grep' above.

Look for 'email' begets the following:

php cfg.php |grep email

You could then use config.php file to hard code a setting ... like $CFG->sometermseenabove='somevalue';

Out of ideas now.

'SoS', Ken

In reply to Ken Task

Re: You don't have permission to view courses here

by Tim Saville -

Ken

Lost me after db???

Do either of the index.php files I attached help?

Regarding your advice below.

You said: 'self based email registrations and forced logins'

From command line ... code/admin/cli/ there is a cfg.phg script which shows settings ... I can access this file from cpanel and modify if needed. Is there code I need to add???

Could try something like:

php cfg.php |grep forced Have no idea about this? Is there code lines in the CLI file that needs to be added? see attcahment.

change the term looking for after the word 'grep' above.

Look for 'email' begets the following:

php cfg.php |grep email

You could then use config.php file to hard code a setting ... like $CFG->sometermseenabove='somevalue'; I tried adding this to Config.php file no change.

I think a new install is the next step.

Regards Tim

Attachment CLI scipts.JPG
Attachment Index.php snapshop 1.JPG
Attachment Index.php snapshot 2.JPG
In reply to Tim Saville

Re: You don't have permission to view courses here

by Ken Task -
Picture of Particularly helpful Moodlers

Brief explanation:

Your cPanel does not offer a terminal (shell) into your account on the server where you are hosted where you could use command line.

Anything in a CLI directory of moodle code can only be executed via command line php-cli.

The cfg.php script when executed from the command line would show all settings.  Was hoping running that would show some variable that you changed.

One should not have to modify tables directly nor change/add any of core moodle code.   Your situation, however, and the error shown think your ownly hope was to at least try to modify tables.

Unless someone has suggestions ... bottom line ...   Yes, start over.   Erase code, moodledata and drop the database for the moodle and install again.

After you get the new one up and running, investigate how you can back it up ... DB dump, code and moodledata archiving ... as well as restore that backup in your hosting environment.

For a while, suggest you do backups after you make major changes as well.

Also, when you begin customizing via Moodle Admin UX, note the 'shortnames' of variables you are setting if they show.   Those 'shortnames' are grayed and normally just below the label seen.   They generally make reference/hints/clues to the backend stuff and handy to know if one should ever need it.

'SoS', Ken

In reply to Dr. Michael Commini

Re: You don't have permission to view courses here

by Colin Fraser -
Picture of Documentation writers Picture of Testers
Ditto to what Ken is suggesting, likely the best option but I would add that if you can't access the server directory where your Moodle is, someone else can and they can perform the changes.

I would also add that whenever you make a change to your settings in any way, whatever change is made, from adding some Additional HTML or changing a theme or hacking the code to change the timeout settings, always document it. You will always have an accurate record of what has been done and perhaps consider the logic behind it. The other issue that if you do make changes it becomes a lot easier to replicate those changes after an update if required.
In reply to Colin Fraser

Re: You don't have permission to view courses here

by Dr. Michael Commini -
@Colin Fraser
Hi Colin,

Yes, I'm able to access the cPanel, so no problem there. Regarding documenting changes, it's a good idea and one I have never followed :D All the changes are in my head and commented on any files I change. Unfortunately, all the changes I made yesterday were in the backend of the site itself as site admin. I remember every one - I just can't access the site to undo them. sad

Regards,

Mike
In reply to Usman Kazi

Ri: You don't have permission to view courses here SOLVED

by Claudio Gasparini -
Same problem: I solved it this way on Moodle 3.8.2
Site administration / Users / Permissions / Define roles / Authenticated user
Click "Edit" and search:
"View list of courses you are not enrolled in [moodle/category:viewcourselist]"
and put "Allow"

Make the same for "Guest" and "Students" if you want.