Broken link for reseting user password
kwielo opened this issue ยท 4 comments
Thanks for using Postleaf! ๐๐
This issue tracker is ONLY for bug reports. If you need help with something or would like to request a feature, please ask on https://community.postleaf.org/ instead.
Issue Summary
Link for reseting user password doesn't have schema, it starts with //
Example:
If this was sent in error, you can ignore this message.
To reset your password, visit this address: //localhost:8000/admin/login/reset/?username=USER&token=84325b15d6dbaf881a594c41654405e7786d8c8726c40abe5484fdecd5564097e40d0e51ea0f4794ac82deff1a1624da9545
It makes it unusable as a proper link.
Steps to Reproduce
Tell us how to replicate the problem.
- Go to login page
- Click on recover my password
- Put your user name and click Continue
- Look for an email in your inbox with a broken link
Additional info
- Postleaf version: master (74b5522)
- PHP version: 7.0
- Affected browsers: n/a
- Operating system: n/a
Provide any additional information that may be relevant to the bug here.
This was broken in c9a3c0a. I'll see what I can come up with for a proper solution.
If we want to send an email, we call Postleaf::url(true).
public static function url($withProtocol = false) {
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
// Get the hostname
$hostname = $_SERVER['HTTP_HOST'];
// Determine if Postleaf is running from a subfolder
$subfolder = self::subfolder();
// Get args and prepend subfolder
$args = func_get_args();
array_unshift($args, $subfolder);
// Remove empties
$args = array_filter($args, 'mb_strlen');
// Glue them together
$path = implode('/', $args);
// Convert backslashes to forward slashes
$path = str_replace('\\', '/', $path);
// Remove duplicate slashes
$path = preg_replace('/\/+/', '/', $path);
// Remove preceding slash
$path = ltrim($path, '/');
// Generate the URL
return ($withProtocol) ? "$protocol://$hostname/$path" : "//$hostname/$path";
}
That will reintroduce the same issue we saw with #57. It also doesn't account for the other URL functions that are wrappers for Postleaf::url()
.
Protocols have been added back to the URL generator, along with a new method to detect SSL.
The old SSL check seemed to work for 99% of environments, and adding the isSsl()
method will make it easier to adjust for edge cases.