Skip to content

Wrong parameter assertions in verifyOTP #1159

Open
@maxfornacon

Description

@maxfornacon

Describe the bug
The verifyOTP method requires to always have either email or phone to be not null. When trying to use the the method with OtpType.recovery and specifying an email I receive AuthException(message: Only the token_hash and type should be provided, statusCode: 400, errorCode: validation_failed).

My workaround is to specify an empty string for email.

To Reproduce
Steps to reproduce the behavior:

This doesn't work with exception from backend.

await Supabase.instance.client.auth.verifyOTP(
        email: email,
        tokenHash: token,
        type: OtpType.recovery,
      );

Exception:

AuthException(message: Only the token_hash and type should be provided, statusCode: 400, errorCode: validation_failed)

This doesn't work with exception from supabase flutter client:

await Supabase.instance.client.auth.verifyOTP(
        tokenHash: token,
        type: OtpType.recovery,
      );
Unhandled Exception: 'package:gotrue/src/gotrue_client.dart': Failed assertion: line 536 pos 12: '(email != null && phone == null) || (email == null && phone != null)': `email` or `phone` needs to be specified.

Expected behavior
Correct checking of which OtpType requires which parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions