FInalized office signup
This commit is contained in:
@@ -17,16 +17,7 @@
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/office/userhome">Office Anmeldung</MudButton>
|
||||
</MudCardActions>
|
||||
</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>
|
||||
</MudContainer>
|
||||
</Authorized>
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
}
|
||||
private void CreateAccount(MouseEventArgs args)
|
||||
{
|
||||
CurrentUser = OfficeState.Value.LdapUsers.GetValueOrDefault(CurrentUserName ?? string.Empty);
|
||||
if (CurrentUser is null) return;
|
||||
Dispatcher.Dispatch(new CreateNewAccountAction(CurrentUser));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ public interface ILdapService
|
||||
{
|
||||
Task<int> GetUserCount(CancellationToken cancellationToken = default);
|
||||
IAsyncEnumerable<LdapUser> GetAllUsers(CancellationToken cancellationToken = default);
|
||||
Task<LdapUser?> GetUser(string uid, CancellationToken cancellationToken = default);
|
||||
Task<int> GetClassroomCount(CancellationToken cancellationToken = default);
|
||||
IAsyncEnumerable<Classroom> GetAllClassrooms(CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -13,8 +13,8 @@ public sealed class OfficeEffects(IOfficeService officeService, ILdapService lda
|
||||
{
|
||||
if (action.UserId is null) return;
|
||||
var graphUser = await officeService.GetUserByAliasesAsync(action.UserId);
|
||||
//var ldapUser = await ldapService.GetUserByUidAsync(action.UserId);
|
||||
dispatcher.Dispatch(new UpdateCurrentUserInfoWithResultAction(action.UserId, graphUser, /*ldapUser.ValueOrDefault*/ null));
|
||||
var ldaUser = await ldapService.GetUser(action.UserId);
|
||||
dispatcher.Dispatch(new UpdateCurrentUserInfoWithResultAction(action.UserId, graphUser, ldaUser));
|
||||
}
|
||||
[EffectMethod]
|
||||
public async Task HandleCreateNewAccountAction(CreateNewAccountAction action, IDispatcher dispatcher)
|
||||
|
||||
Reference in New Issue
Block a user