lacoctelera::authentication

Function verify_token

Source
pub fn verify_token(
    expected_token: SecretString,
    given_token: SecretString,
) -> Result<(), DataDomainError>
Expand description

Check if a given token matches the hash stored in the DB.

ยงDescription

This function receives two values: the stored hash of the token in the DB, and the token used by the client in a request to the API. The function hashes the given token and compares both. If both match, Ok(()) is returned, and an Err(InvalidAccessCredentials) otherwise.