Authentication
Call get_user() at the top of the script to require login. It triggers a login prompt if the user is not authenticated and returns an object with a .email attribute.
In the editor's previews, get_user() returns you, without a login prompt. To check what another user sees, use Test as another user in the preview and pick an email and roles: get_user() then returns that user.
Filtering by the logged-in user
A common pattern is to fetch only the tasks or records that belong to the current user: