Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 Hotfix registration #1561

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface IUserInformationService
Task<bool> UpdatePortalUserAsync(PortalUser updatedUser);
public event EventHandler<PortalUserUpdatedEventArgs> PortalUserUpdated;
Task<bool> IsDailyLogin();
Task<bool> CheckUserInTenant(string email);
}

public static class UserInformationServiceConstants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,9 @@ public Task<bool> IsDailyLogin()
{
return Task.FromResult(false);
}

public Task<bool> CheckUserInTenant(string email)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,13 @@ public async Task<PortalUser> GetPortalUserWithAchievementsAsync(string userGrap

return portalUser;
}

public async Task<bool> CheckUserInTenant(string email)
{
PrepareAuthenticatedClient();
var users = await graphServiceClient.Users.GetAsync(
test => test.QueryParameters.Filter = $"mail eq '{email}'");
if (users?.Value != null) return users.Value.Count > 0;
return false;
}
}
18 changes: 15 additions & 3 deletions Portal/src/Datahub.Portal/Pages/Public/Login.razor
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,34 @@
_loggingIn = true;
var loginHint = loginModel.Email;
var existingUser = await _userInformationService.GetPortalUserByEmailAsync(loginHint);

// If user is deleted, redirect to register page with deleted flag
if (existingUser is { IsDeleted: true })
{
_navigationManager.NavigateTo($"{Localizer["/register"]}?email={loginHint}&s=d");
return;
}

// If user is locked, redirect to locked page
if (existingUser is { IsLocked: true })
{
_navigationManager.NavigateTo(Localizer["/locked"]);
return;
}


// If there is no portal user associated with the email, then:
if (existingUser is null)
{
_navigationManager.NavigateTo($"{Localizer["/register"]}?email={loginHint}&s=n");
return;
// - first check if the user is registered in the tenant (that means they have registered but not logged in yet)
var registered = await _userInformationService.CheckUserInTenant(loginHint);

// - if not registered, redirect to register page with new flag
if (!registered)
{
_navigationManager.NavigateTo($"{Localizer["/register"]}?email={loginHint}&s=n");
return;
}
// - if they are registered, proceed with the normal login flow
}

if (string.IsNullOrWhiteSpace(redirectUri))
Expand Down