Skip to content

Error when trying to access the register page #1143

@OnlyOneBDS

Description

@OnlyOneBDS

Using the following code:

public partial class SelfRegister
{
  [Inject] private IUsersClient UsersClient { get; set; } = default!;

  private readonly CreateUserRequest _createUserRequest = new();
  private bool BusySubmitting { get; set; }

  private CustomValidation? _customValidation;
  private bool _passwordVisibility;

  private InputType _passwordInput = InputType.Password;
  private string _passwordInputIcon = Icons.Material.Filled.VisibilityOff;

  private List<SchoolLiteDto> _schools = [];

  protected override async Task OnInitializedAsync()
  {
    await LoadSchools();
  }

  private async Task LoadSchools()
  {
    if (await ApiHelper.ExecuteCallGuardedAsync(() => UsersClient.GetSchoolsListAsync(), Snackbar, NavigationManager) is ICollection<SchoolLiteDto> response)
    {
      _schools = [.. response];
    }
  }

  private async Task SubmitAsync()
  {
    BusySubmitting = true;

    string? sucessMessage = await ApiHelper.ExecuteCallGuardedAsync(() => UsersClient.SelfRegisterAsync(_createUserRequest), Snackbar, NavigationManager, _customValidation);

    if (sucessMessage != null)
    {
      Snackbar.Add(sucessMessage, Severity.Info);
      NavigationManager.NavigateTo("login");
    }

    BusySubmitting = false;
  }

  private void TogglePasswordVisibility()
  {
    if (_passwordVisibility)
    {
      _passwordVisibility = false;
      _passwordInputIcon = Icons.Material.Filled.VisibilityOff;
      _passwordInput = InputType.Password;
    }
    else
    {
      _passwordVisibility = true;
      _passwordInputIcon = Icons.Material.Filled.Visibility;
      _passwordInput = InputType.Text;
    }
  }
}

I'm trying to add a MudSelect that is populated from a table in the database. When I click on the register link, the page "flickers" and I'm back at the login page. Looking in Network tab in dev tools, the data comes back with no issue. This is what the Console window looks like.

Image

When I comment out the "await LoadSchools()" line, I'm able to access the register page. Why is this happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions