Skip to content

Throw if storing token without userID and AthleteID in Cosmos layer #51

@benCoomes

Description

@benCoomes

Currently, all domain-level code ensures that tokens are stored with both a UserID and AthleteID. However, the database layer would store a token without a UserID, if it were asked to. This must be allowed currently because some tokens still exist from before user authentication was implemented, and so there is no associated user. Once this is no longer the case and all current tokens have a UserID, the data layer should enforce the existence of a UserID as an added protection against corrupt data.

In practice, changing this assertion to check that the statement throws and then ensuringthe test passes is what is required for this issue:

await tryMissingUser.Should().NotThrowAsync();

Also see

public bool IsValid()
{
// todo: check UserID as well. Right now, existing tokens in prod don't have a user ID.
// because they were created before authentication was implemented.
return AthleteID != 0; // && !string.IsNullOrWhiteSpace(UserID);
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions