Hotspot Send Email on Trial User login.
Posted: Thu Jul 04, 2013 9:23 pm
Wanted to get an Email when a new trial account logs in.
We only wanted Trial users to be able to login once (no reset).
Trial users is deleted when router reboots....WE DONT WANT THAT.
OBS : You need to get email sending working on your router before doing this.
Tested on ROS 6.1
Here is what i came up with :
1: Create a hotspot user profile for disabled trial users.
2: On Trilal user profile edit and add the following "On Login" script.
This will grab users ip and mac-address and send you an Email on login.
3: On Trilal user profile, add the following "On Logout" script.
This will delete the dynamic Trial user, and add a permanent user instead, to prevent more than 1 trial period.
And if somone manages to login anyway, they will get a very shitty connection
Just wanted to share
We only wanted Trial users to be able to login once (no reset).
Trial users is deleted when router reboots....WE DONT WANT THAT.
OBS : You need to get email sending working on your router before doing this.
Tested on ROS 6.1
Here is what i came up with :
1: Create a hotspot user profile for disabled trial users.
Code: Select all
/ip hotspot user profile add add-mac-cookie=no idle-timeout=1s keepalive-timeout=1s name=getlost rate-limit=1k/1k session-timeout=1s status-autorefresh=60m transparent-proxy=yes
This will grab users ip and mac-address and send you an Email on login.
Code: Select all
:local freeuser
:set freeuser "$user"
:local freeuserno [/ip hotspot active find where user=$freeuser];
:local freemac [/ip hotspot active get $freeuserno mac-address];
:local freeip [/ip hotspot active get $freeuserno address];
:local emailaddress "YOUREMAIL@YOURDOMAIN:COM"
:local date [/system clock get date]
:local time [/system clock get time]
:local emailsubject
:local emailbody
:set emailsubject "New Hotspot Login ($freeuser)"
:set emailbody "Trial: $freemac\r\n$time, $date\r\nIP: $freeip\r\n";
/tool e-mail send to="$emailaddress" subject="$emailsubject" body="$emailbody"
This will delete the dynamic Trial user, and add a permanent user instead, to prevent more than 1 trial period.
And if somone manages to login anyway, they will get a very shitty connection
Code: Select all
:local freeuser
:set freeuser "$user"
:local freeuserno [/ip hotspot user find where name=$freeuser];
:local freemac [/ip hotspot user get $freeuserno mac-address];
/ip hotspot user remove $freeuser
/ip hotspot user add name=$freeuser password=disabled profile=getlost mac-address=$freemac