Difference between revisions of "GDPR"
(→Last Login Time) |
(→Last Login Time) |
||
Line 25: | Line 25: | ||
my( @local ) = localtime( time ); | my( @local ) = localtime( time ); | ||
my ( $sec, $min, $hour, $day, $mon, $year ) = ( $local[0], $local[1], $local[2], $local[3], $local[4]+1, $local[5]+1900 ); | my ( $sec, $min, $hour, $day, $mon, $year ) = ( $local[0], $local[1], $local[2], $local[3], $local[4]+1, $local[5]+1900 ); | ||
− | my $loginTime = "$year-$mon-$ | + | my $loginTime = "$year-$mon-$day $hour:$min:$sec"; |
#store the value | #store the value |
Revision as of 10:57, 25 April 2018
This page has been created to gather information and share code snippets to help EPrints repositories handle GDPR responsibilities.
Last Login Time
Storing the last login time of a user can be useful to identify which users are active and which are not to help ensure data is not being stored longer than is necessary.
First a new user field for storing the time is required in user_fields.pl
push @{$c->{fields}->{user}},
{
'name' => 'last_login',
'type' => 'timestamp',
},
};
And then add the following code to $c->{check_user_password} in user_login.pl to store the time at which a user successfully logs in.
#get user from username
my $user = EPrints::DataObj::User::user_with_username( $repository, $username );
#get time and compile a string
my( @local ) = localtime( time );
my ( $sec, $min, $hour, $day, $mon, $year ) = ( $local[0], $local[1], $local[2], $local[3], $local[4]+1, $local[5]+1900 );
my $loginTime = "$year-$mon-$day $hour:$min:$sec";
#store the value
$user->set_value( "last_login", $loginTime );
$user->commit();
#return user
return 1;
Non-Active Users Report
TODO
Delete User Action
TODO