GraseHotspot / grase-www-portal

Grase WWW Portal (Main Package)
51 stars 20 forks source link

User expiration after first login (Trac #39) #39

Closed ghost closed 9 years ago

ghost commented 10 years ago

When the user gets used for the first time a countdown starts which will cause the user to be expired 'x' days form first log-in This yould be useful for visitors

Migrated from http://trac.grasehotspot.org/ticket/39

{
    "status": "accepted", 
    "changetime": "2012-10-18T00:31:58", 
    "description": "When the user gets used for the first time a countdown starts which will cause the user to be expired 'x' days form first log-in\nThis yould be useful for visitors", 
    "reporter": "Vedran84", 
    "cc": "", 
    "resolution": "", 
    "_ts": "1350520318767444", 
    "component": "Coova Chilli", 
    "summary": "User expiration after first login", 
    "priority": "major", 
    "keywords": "", 
    "version": "3.6", 
    "time": "2011-11-11T17:40:36", 
    "milestone": "3.8", 
    "owner": "tim", 
    "type": "enhancement"
}
ghost commented 10 years ago

Trac update at 20121018T00:31:58:

This will also help with cleaning up of expired users, as a ticket could have an activation expiry of 6 months, but a usage expiry of 7 days, and so could be cleaned up almost 5 months earlier in some cases.

  • tim changed priority from "minor" to "major"
  • tim changed status from "new" to "accepted"
timwhite commented 10 years ago

Something like the following works if we don't have the monthly jobs summarise the radacct table into mtotacct.

    sqlcounter accessperiod {
                counter-name = Max-Access-Period-Never
                check-name = Access-Period
                sqlmod-inst = sql
                key = User-Name
                reset = never
                query = "SELECT IF(COUNT(radacctid>=1),(UNIX_TIMESTAMP() - IFNULL(UNIX_TIMESTAMP(AcctStartTime),0)),0) FROM radacct WHERE UserName = '%{%k}' AND AcctSessionTime >= 1 ORDER BY AcctStartTime LIMIT 1"
        }

Ideally, we combine something like this, with a nightly cron job that then sets a valid expiry on that user once it's first activated, so even at first login, we can have it work, and for an expiry of say "+6 months" from first use, it will also work.

timwhite commented 10 years ago

Initial POC in the grase-conf-freeradius nightly package. To use, insert a line into the database like follows

INSERT INTO `radius`.`radcheck` (`UserName`, `Attribute`, `op`, `Value`) VALUES ('tim', 'GRASE-ExpireAfter', ':=', '+1 month');

The format of ExpireAfter is anything that can be parsed with the perl parsedate function (http://search.cpan.org/~muir/Time-ParseDate-2013.1113/lib/Time/ParseDate.pm)

timwhite commented 9 years ago

Basic GUI in 932bd8db2d4a7a113c0b832771db9b83402a5557 Still need Cronjob to allow expire after dates of more than 1 month.

timwhite commented 9 years ago

Cronjob done in 25ece46790b049c02ccac4b6f32221489b0adeac