Skip to content

refreshSession shouldn't fail because currentSession doesn't exists if the refreshToken is provided #1261

@Aadim1

Description

@Aadim1

Describe the bug
Much like the title, I don't think this is a correct behavior, mostly because supabase-flutter is already doing this Nullish coalescing check anyway.

Future<AuthResponse> refreshSession([String? refreshToken]) async {
    if (currentSession?.accessToken == null) {
      _log.warning("Can't refresh session, no current session found.");
      throw AuthSessionMissingException();
    }
    _log.info('Refresh session');

    final currentSessionRefreshToken =
        refreshToken ?? _currentSession?.refreshToken;

    if (currentSessionRefreshToken == null) {
      throw AuthSessionMissingException();
    }

    return await _callRefreshToken(currentSessionRefreshToken);
  }

This code snippets, realistically only needs this piece of code:

if (currentSessionRefreshToken == null) {
      throw AuthSessionMissingException();
    }

The first one doesn't seem right to me. That check is also not doing anything, and blocks a valid use-case where you might have a refreshToken but no current session atm.

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