Page 1 of 1
FEU delete expired users automatically
Posted: Wed Mar 20, 2019 12:30 pm
by aerdna
hello there
I have got a question concerning the FrontentUser Module.
Is it possible to delete the users automatically after their account expires?
And if, I would like to know how
The reason I ask is, because the site I'm currently working on will have hundreds of user, which will be active for max. 5 years and the customer does not want to delete theme manually after the accounts expire.
thanks in advance

andrea
P.S.: there was already a topic with the same issue, but there was no feedback, so I hope it's okey that I created a new one
Re: FEU delete expired users automatically
Posted: Thu Mar 21, 2019 10:31 am
by rotezecke
I dont have an answer for you but I'm sure it's possible with the new commands for cmscli. probably with a single line of code (which I have not figured out yet).
Basically, you need to list the expired accounts and then pipe the result to the delete command. all new commands can be found in modules/FrontEndUsers/lib/Commands folder.
assuming you have cmscli installed and working, and are in that directory, you can list all users using
Code: Select all
sudo -u www-data php cmscli.phar -d /path/to/cmsms feu-user-list
I don't know how to use the expired filter but maybe someone can weigh in here?
once this works, all you need is a cronjob on the server. Calguy mentioned that the command names may change but that would be an easy fix.
Re: FEU delete expired users automatically
Posted: Wed Mar 27, 2019 12:09 pm
by aerdna
to be honest I'm unfamiliar with cmscli, because I haven't used it before, but if it's the only way I will have to try it, thank you for the suggestion
isn't there maybe a way with the existing functions from the module?
when there is a function that sets the user to expired, is it possible to trigger the delete from there?
Re: FEU delete expired users automatically
Posted: Thu Mar 28, 2019 5:35 pm
by PinkElephant
Hi,
I'm not that familiar with FEU but...
aerdna wrote:isn't there maybe a way with the existing functions from the module?
I doubt it because the Help file indicates the functionality is deliberately missing to avoid other modules falling over.
when there is a function that sets the user to expired, is it possible to trigger the delete from there?
I don't know but it's the sort of hook I'd expect to see.
Meanwhile, going via cmscli...
Code: Select all
cmscli feu-user-add blackdog1 brilliant-passsword 'Group 001'
cmscli feu-user-add blackdog2 brilliant-passsword 'Group 001'
cmscli feu-user-edit blackdog1 --expires 'yesterday'
cmscli feu-user-edit blackdog2 --expires 'yesterday'
cmscli feu-user-list --expired
6 blackdog2
5 blackdog1
(Use feu-user-list --expired -j for all field values in json format)
How you deal with the output is down to environment but under bash, a bare bones approach might look like this;
Code: Select all
#!/bin/bash
for user in $( cmscli feu-user-list --expired | awk '{print $2}' ); do
echo $user will be destroyed
cmscli feu-user-del "$user"
done
That's throwing a php notice here (CMSCLI 0.5, CMSMS 2.2.8, FEU 2.13, CGExtensions 1.61.5) but the expired users are no more.
Code: Select all
PHP Notice: Undefined index: REMOTE_ADDR in .../htdocs/cmsms2/modules/CGExtensions/lib/class.cge_utils.php on line 421
Re: FEU delete expired users automatically
Posted: Fri Mar 29, 2019 7:53 pm
by rotezecke
little warning (or call for help:) there seems to be a bug if cmscli is NOT inside the root directory of CMSMS. you can define the directory using the -d switch, but that does not work in combination with --expired. At least I could not get it to work. as single line (for cron maybe - assuming cmsms and cmscli in same directory)
Code: Select all
/usr/bin/php /path/to/cmscli feu-user-list --expired | awk '{print $2}' | xargs -r -n1 /usr/bin/php /path/to/cmscli feu-user-del
Re: FEU delete expired users automatically
Posted: Sat Mar 30, 2019 7:24 pm
by PinkElephant
rotezecke wrote:seems to be a bug if cmscli is NOT inside the root directory of CMSMS.
It's working as expected here...
admin@vm1:~$ which cmscli
/srv/.all-sites/utils/cmscli
admin@vm1:~$ cd /srv/[xxx]/public/htdocs/cmsms2
admin@vm1:~/[xxx]/public/htdocs/cmsms2$ cmscli feu-user-list
4 blackdog4
3 blackdog3
admin@vm1:~/[xxx]/public/htdocs/cmsms2$ cmscli feu-user-list --expired
3 blackdog3
admin@vm1:~/[xxx]/public/htdocs/cmsms2$ ls cmscli
ls: cannot access 'cmscli': No such file or directory