Custom user validation

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sclg
User
Posts: 153
Location: UK

Custom user validation

Post by sclg »

Updating a working 2023 project to 2024.
It uses a custom user validation to validate against a Joomla user database and I had to change the d/b handling from dbConnect to Conn. This is obviously working as it does login but after that it goes to the url http://localhost/pipers2024/index which shows a blank page.
If I delete the '/index' and refresh, it goes to http://localhost/pipers2024/rangedateslist which is the correct default page and displays correctly.

Why is it trying to go to /index on login instead of the correct page??

Thanks


arbei
User
Posts: 9427

Post by arbei »

  1. If you meant you use User_CustomValidate server event, make sure you return true if the user is valid.
  2. "/index" is same as "/" and it will redirect the user to the Start Page you set up in your project or the first page that the user has permission. You may want to check your Start page setting and make sure it is a valid path (that all user has permission to go to). Otherwise you should leave it empty, don't set it as "index".

sclg
User
Posts: 153
Location: UK

Post by sclg »

Yes - User_CustomValidate returns true.
The Start page setting is blank.
The order of events is this...

URL - http://localhost/pipers2024/login
Shows login screen as normal. When I login, URL shows http://localhost/pipers2024/index and I get a completely blank screen.
I can refresh with F5 or CTRL-F5 but the screen stays blank

If I now delete the word 'index' from the URL in the address bar so that it says http://localhost/pipers2024/ and then press Enter, I go to the correct page - the URL says http://localhost/pipers2024/rangedateslist and the correct page is displayed.
(rangedates is set as 'default' in the table settings.)

In summary, http://localhost/pipers2024/index ALWAYS gives a blank page whereas http://localhost/pipers2024/ ALWAYS goes to the right place.


mobhar
User
Posts: 11761

Post by mobhar »

Make sure you have already given at least List permission for rangedateslist page.


sclg
User
Posts: 153
Location: UK

Post by sclg »

I have - and I get the same problem even if I login as the hard-coded administrator.


mobhar
User
Posts: 11761

Post by mobhar »

Did you have code in User_CustomValidate server event that redirect to the certain URL?


sclg
User
Posts: 153
Location: UK

Post by sclg »

Not as far as I know. Code is...

function User_CustomValidate(&$usr, &$pwd) {
	// Enter your custom code to validate user, return TRUE if valid.

global $jmdb;

	$jpassword = password_hash($pwd, PASSWORD_BCRYPT);
	$mysql = "SELECT password FROM jos_users WHERE username = '".$usr."'";
	$enteredp = $jmdb->fetchOne($mysql);
	if (password_verify($pwd, $enteredp)) {
		return TRUE;
		} else {
	return FALSE;
	}
}

arbei
User
Posts: 9427

Post by arbei »

  1. You got blank screen probably because you had PHP error but display_errors is off, you should turn on Debug, check your php.ini, run again and then check the log files.
  2. You may also remove your User_CustomValidate server event and test.
    ( Not related to your question, but the $jpassword is unused in your code.)

Post Reply