FInalized office signup

This commit is contained in:
Rhywden
2026-08-31 08:39:15 +02:00
parent 04f7f527be
commit d2db6a8b6c
5 changed files with 29 additions and 12 deletions
+1 -10
View File
@@ -17,16 +17,7 @@
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/office/userhome">Office Anmeldung</MudButton> <MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/office/userhome">Office Anmeldung</MudButton>
</MudCardActions> </MudCardActions>
</MudCard> </MudCard>
<MudCard Style="width: 300px;">
<MudCardMedia Image="images/questionnaire.svg" Height="200" Style="width: 300px;" />
<MudCardContent>
<MudText Typo="Typo.h5">Umfragen</MudText>
<MudText Typo="Typo.body2">Hier kannst du an Umfragen teilnehmen.</MudText>
</MudCardContent>
<MudCardActions>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/students/questionaire">Umfragen</MudButton>
</MudCardActions>
</MudCard>
</MudStack> </MudStack>
</MudContainer> </MudContainer>
</Authorized> </Authorized>
@@ -161,6 +161,7 @@
} }
private void CreateAccount(MouseEventArgs args) private void CreateAccount(MouseEventArgs args)
{ {
CurrentUser = OfficeState.Value.LdapUsers.GetValueOrDefault(CurrentUserName ?? string.Empty);
if (CurrentUser is null) return; if (CurrentUser is null) return;
Dispatcher.Dispatch(new CreateNewAccountAction(CurrentUser)); Dispatcher.Dispatch(new CreateNewAccountAction(CurrentUser));
} }
@@ -6,6 +6,7 @@ public interface ILdapService
{ {
Task<int> GetUserCount(CancellationToken cancellationToken = default); Task<int> GetUserCount(CancellationToken cancellationToken = default);
IAsyncEnumerable<LdapUser> GetAllUsers(CancellationToken cancellationToken = default); IAsyncEnumerable<LdapUser> GetAllUsers(CancellationToken cancellationToken = default);
Task<LdapUser?> GetUser(string uid, CancellationToken cancellationToken = default);
Task<int> GetClassroomCount(CancellationToken cancellationToken = default); Task<int> GetClassroomCount(CancellationToken cancellationToken = default);
IAsyncEnumerable<Classroom> GetAllClassrooms(CancellationToken cancellationToken = default); IAsyncEnumerable<Classroom> GetAllClassrooms(CancellationToken cancellationToken = default);
} }
+24
View File
@@ -39,6 +39,30 @@ public sealed class LdapService(IOptions<LdapOptions> options) : ILdapService
} }
} }
public Task<LdapUser?> GetUser(string uid, CancellationToken cancellationToken = default)
{
ArgumentException.ThrowIfNullOrWhiteSpace(uid);
cancellationToken.ThrowIfCancellationRequested();
using var connection = CreateConnection();
var studentRoleDn = BuildDistinguishedName(_options.StudentsRole, _options.RoleBase);
var teacherRoleDn = BuildDistinguishedName(_options.TeacherRole, _options.RoleBase);
var request = new SearchRequest(
BuildDistinguishedName(_options.UserBase),
$"(&(uid={EscapeFilterValue(uid)}){GetSupportedRolesFilter(studentRoleDn, teacherRoleDn)})",
SearchScope.Subtree,
"uid",
"sn",
"givenName",
"memberOf");
var response = (SearchResponse)connection.SendRequest(request);
return Task.FromResult(response.Entries
.Cast<SearchResultEntry>()
.Select(entry => CreateUser(entry, studentRoleDn, teacherRoleDn))
.SingleOrDefault());
}
public Task<int> GetClassroomCount(CancellationToken cancellationToken = default) public Task<int> GetClassroomCount(CancellationToken cancellationToken = default)
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@@ -13,8 +13,8 @@ public sealed class OfficeEffects(IOfficeService officeService, ILdapService lda
{ {
if (action.UserId is null) return; if (action.UserId is null) return;
var graphUser = await officeService.GetUserByAliasesAsync(action.UserId); var graphUser = await officeService.GetUserByAliasesAsync(action.UserId);
//var ldapUser = await ldapService.GetUserByUidAsync(action.UserId); var ldaUser = await ldapService.GetUser(action.UserId);
dispatcher.Dispatch(new UpdateCurrentUserInfoWithResultAction(action.UserId, graphUser, /*ldapUser.ValueOrDefault*/ null)); dispatcher.Dispatch(new UpdateCurrentUserInfoWithResultAction(action.UserId, graphUser, ldaUser));
} }
[EffectMethod] [EffectMethod]
public async Task HandleCreateNewAccountAction(CreateNewAccountAction action, IDispatcher dispatcher) public async Task HandleCreateNewAccountAction(CreateNewAccountAction action, IDispatcher dispatcher)