token creation algorithm

More
5 days 15 hours ago #206720 by tassoman
Hello there,
is it possible to write a plugin hooking to token creation event?

I would like to avoid random string generation and substitute it with random word token creation.
Alphanumeric token it's really difficult to remember.

So my ideal token would be a selection of random dictionary words and a numeric code. For example: dog-apple-434, cat-pear-221, rat-melon-364, horse-orange-996 etc etc...

«All your survey answers are belong to us »

Please Log in to join the conversation.

LimeSurvey Partners
More
5 days 14 hours ago - 5 days 14 hours ago #206723 by DenisChenu
Replied by DenisChenu on topic token creation algorithm
In 4.X you have an event (i must check if it was in manual)

And a sample core plugin
github.com/LimeSurvey/LimeSurvey/tree/ma.../plugins/customToken

Not in 4.X Not in 3.X

See bugs.limesurvey.org/view.php?id=15026

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.
Last edit: 5 days 14 hours ago by DenisChenu. Reason: Not in 3.X

Please Log in to join the conversation.

More
5 days 14 hours ago #206726 by DenisChenu
Replied by DenisChenu on topic token creation algorithm

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.

Please Log in to join the conversation.

More
5 days 11 hours ago #206733 by tassoman
Replied by tassoman on topic token creation algorithm
Thank you Denis for your complete reply.
I can understand branch 3.x development is now frozen for features. Just security patches.
So the team accepts new features only on 4.x branch.

This feature is available in LS since 3.17.x the only effort is to write a plugin who define the token creation behaviour. In detail I must hook to afterGenerateToken event

github.com/LimeSurvey/LimeSurvey/pull/13...f9ab2fb344877c925R13

Last question is: because my token doesn't have a fixed length, should I keep NULL $event->get('iTokenLength'); ?

«All your survey answers are belong to us »

Please Log in to join the conversation.

More
5 days 11 hours ago - 5 days 11 hours ago #206734 by DenisChenu
Replied by DenisChenu on topic token creation algorithm

tassoman wrote: This feature is available in LS since 3.17.x the only effort is to write a plugin who define the token creation behaviour. In detail I must hook to afterGenerateToken event


Are you sure ?
[shnoulle@poledra 3LTS]$ cd application/
[shnoulle@poledra application]$ grep -r "afterGenerateToken" *

tassoman wrote: Last question is: because my token doesn't have a fixed length, should I keep NULL $event->get('iTokenLength'); ?

Maybe an issue with inherited or something like that ?
4.X ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.
Last edit: 5 days 11 hours ago by DenisChenu.

Please Log in to join the conversation.

More
5 days 9 hours ago #206739 by tassoman
Replied by tassoman on topic token creation algorithm

DenisChenu wrote: Are you sure ?


Well ... No I've did a mistake. The hook was added only inside the 4.x branch.

Do you think I have a chance to extend the method named generateToken inside the Token model by writing a plugin?

«All your survey answers are belong to us »

Please Log in to join the conversation.

More
4 days 20 hours ago - 4 days 20 hours ago #206744 by DenisChenu
Replied by DenisChenu on topic token creation algorithm

tassoman wrote:

DenisChenu wrote: Are you sure ?


Well ... No I've did a mistake. The hook was added only inside the 4.x branch.

Do you think I have a chance to extend the method named generateToken inside the Token model by writing a plugin?

I don't find how … maybe … but really didn't know …

The current alternative i use to replace core system it's beforeControllerAction : then i con do what i want but need to construct the whole controller
Sample : framagit.org/SondagePro-LimeSurvey-plugi...dminStatitistics.php (old one , unsure its still work …)

PS : maybe you can ask to move this event in next 3.X version ? Seems new feature is accepted again in 3.X …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development . I don't answer to private message.
Last edit: 4 days 20 hours ago by DenisChenu. Reason: PS
The following user(s) said Thank You: tassoman

Please Log in to join the conversation.

More
4 days 20 hours ago - 4 days 20 hours ago #206746 by tassoman
Replied by tassoman on topic token creation algorithm
I wrote a note in the issue tracker to link the feature request to this topic.

I dunno if can be wise to accept new features inside 3.x branch. In my opinion you'll end up having community never upgrading to 4.x branch.

I feel I can write two extending classes inside my plugin php file.
In the worst case I'm going to have an error of class not initialized.

PS: in Matomo project they accept backports on 3.x branch by pull request merge. It means you can checkout 4.x, copy the code you need, create a new branch 3.x-myfeat then ask to merge this branch to that 3.x-dev.
It's a smart decision, I've already did in the past. They only accept backports merged by community.

«All your survey answers are belong to us »
Last edit: 4 days 20 hours ago by tassoman. Reason: note on backporting
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now