argument('user_id'); if ($userId === 0) { return $this->failWith('CANNOT_REVOKE_ROOT_USER'); } $user = User::find($userId); if (! $user) { return $this->failWith('USER_NOT_FOUND'); } $user->forceFill([ 'password' => Hash::make(Str::random(64)), // MapleDeploy branding: OAuth login matches by email, so keep a // persistent marker that the callback can reject after revocation. 'remember_token' => 'mapledeploy-revoked:'.Str::random(40), ])->save(); $user->tokens()->delete(); // MapleDeploy branding: revocation must end any active browser sessions. DB::table('sessions')->where('user_id', $user->id)->delete(); $this->line(json_encode([ 'revoked' => [ 'id' => $user->id, 'email' => $user->email, ], ], JSON_THROW_ON_ERROR)); return self::SUCCESS; } private function failWith(string $code): int { $this->line(json_encode(['error' => $code], JSON_THROW_ON_ERROR)); return self::FAILURE; } }