CodeIgniter Forums
CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing (/showthread.php?tid=65560)



CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - ivantcholakov - 06-26-2016

In CodeIgniter 4 Pre-Alpha 1 there is built-in feature for obfuscating ID's that is managed by the sort of "mini-AR" for models. So, this is and example from the documentation:

Code:
// Creates something like: http://exmample.com/users/MTIz
$url = '/users/'. $model->encodeID($user->id);

I think, there should be introduced a placeholder (a named sub-pattern) within the router that is to recognize the corresponding hashes. currently there are these placeholders:
(:any)
(:segment)
(:num)
(:alpha)
(:alphanum)

If the format of the resulting hash makes possible it to be distinguished with reliability then a new placeholder for routing patterns can be introduced, (:hash) or with similar name.


RE: CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - kilishan - 06-26-2016

That's a good idea, since it's a readability thing. It's good to glance at your routes and know which are hashed id's and which are something else.

I'll just have to go back through and make sure that I properly account for all possible characters.


RE: CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - kilishan - 06-27-2016

And - this is done and in the repo as of last night. Thanks for the idea!


RE: CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - ivantcholakov - 06-27-2016

Thank you.


RE: CodeIgniter 4 Pre-Alpha 1: Obfuscated IDs and routing - phambinh217 - 06-27-2016

yes, it is good idea! lile fuel