Skip to content

Commit

Permalink
Revert "Add last_activity to user for better gauging if users are sti…
Browse files Browse the repository at this point in the history
…ll active"

This reverts commit 5a6cfb5.
  • Loading branch information
HerrLevin committed Jun 16, 2024
1 parent 5a6cfb5 commit 742c40a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class AccountDeletionController extends Controller
{

private static function getInactiveUsersSinceWeeks(int $weeks): Collection {
return User::where('users.last_activity', '<', now()->subWeeks($weeks))
return User::where('users.last_login', '<', now()->subWeeks($weeks))
->whereNotNull('email')
->get()
->filter(static function(User $user) use ($weeks) {
Expand Down
17 changes: 0 additions & 17 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@

class Authenticate extends Middleware
{
public function handle($request, $next, ...$guards) {
parent::handle($request, $next, ...$guards);

if (empty($guards)) {
$guards = [null];
}

foreach ($guards as $guard) {
if ($this->auth->guard($guard)?->user()?->last_activity?->diffInMinutes(now()) > 60){
$this->auth->guard($guard)->user()->last_activity = now();
$this->auth->guard($guard)->user()->save();
}
}

return $next($request);
}

/**
* Get the path the user should be redirected to when they are not authenticated.
*
Expand Down
4 changes: 1 addition & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* @property Carbon last_login
* @property Status[] $statuses
* @property SocialLoginProfile socialProfile
* @property Carbon last_activity
*
* @todo replace "role" with an explicit permission system - e.g. spatie/laravel-permission
* @todo replace "experimental" also with an explicit permission system - user can add self to "experimental" group
Expand All @@ -61,7 +60,7 @@ class User extends Authenticatable implements MustVerifyEmail
protected $fillable = [
'username', 'name', 'avatar', 'email', 'email_verified_at', 'password', 'home_id', 'privacy_ack_at',
'default_status_visibility', 'likes_enabled', 'private_profile', 'prevent_index', 'privacy_hide_days',
'language', 'last_login', 'mapprovider', 'timezone', 'last_activity'
'language', 'last_login', 'mapprovider', 'timezone',
];
protected $hidden = [
'password', 'remember_token', 'email', 'email_verified_at', 'privacy_ack_at',
Expand All @@ -83,7 +82,6 @@ class User extends Authenticatable implements MustVerifyEmail
'privacy_hide_days' => 'integer',
'last_login' => 'datetime',
'mapprovider' => MapProvider::class,
'last_activity' => 'datetime',
];

public function getTrainDistanceAttribute(): float {
Expand Down

0 comments on commit 742c40a

Please sign in to comment.