Skip to content

Commit

Permalink
Merge pull request #397 from Blazam-App/Beta-Dev
Browse files Browse the repository at this point in the history
Nightly Update
  • Loading branch information
jacobsen9026 authored Jun 9, 2024
2 parents 1e46d2b + b70f25c commit 32e84c8
Show file tree
Hide file tree
Showing 61 changed files with 33,430 additions and 11,252 deletions.
2 changes: 1 addition & 1 deletion BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>0.9.3</AssemblyVersion>
<Version>2024.05.27.2131</Version>
<Version>2024.06.09.1748</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
Expand Down
68 changes: 68 additions & 0 deletions BLAZAM/Pages/Configure/EmailTemplateSettings.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@page "/notifications"
@attribute [Authorize(Roles = UserRoles.SuperAdmin)]

@inherits TabbedAppComponentBase

<AppPageTitle>@AppLocalization["Notifications"]</AppPageTitle>
<AuthorizeView Roles=@UserRoles.SuperAdmin>

<SetHeader>
</SetHeader>




<MudTabs ActivePanelIndex="@ActiveTab">
<MudTabPanel>
<ChildContent>


<NotificationTemplates />


</ChildContent>
<TabContent>
@AppLocalization["Templates"]
</TabContent>
</MudTabPanel>
<MudTabPanel>
<ChildContent>


<AccessLevelEditor />


</ChildContent>
<TabContent>
@AppLocalization["Access Levels"]
</TabContent>

</MudTabPanel>
<MudTabPanel>
<ChildContent>

@if (Monitor.DirectoryConnectionStatus == ServiceConnectionState.Up)
{
<ImpersonateUser />
<PermissionMapper />

}


</ChildContent>
<TabContent>
@AppLocalization["Mappings"]
</TabContent>

</MudTabPanel>

</MudTabs>



</AuthorizeView>


@code {

}
7 changes: 5 additions & 2 deletions BLAZAM/Pages/Configure/Templates.razor
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<MudTooltip Text="@AppLocalization["Rename Category"]">
<MudIconButton OnClick=@(()=>{RenameModal?.Show();})
Color="Color.Tertiary"
Class="align-middle"
Icon="@Icons.Material.Filled.ChangeCircle" />
</MudTooltip>
}
Expand All @@ -70,6 +71,7 @@

<MudIconButton OnClick=@(async()=>{await DuplicateTemplate(SelectedTemplate);})
Color="Color.Tertiary"
Class="align-middle"
Icon="@Icons.Material.Filled.FileCopy" />
</MudTooltip>
<MudTooltip Text="@AppLocalization["Remove template"]">
Expand All @@ -88,6 +90,7 @@

<MudIconButton OnClick=@(async()=>{RestoreModal?.Show();})
Color="Color.Warning"
Class="align-middle"
Icon="@Icons.Material.Filled.RestoreFromTrash" />
</MudTooltip>
}
Expand Down Expand Up @@ -190,7 +193,7 @@
SnackBarService.Success(AppLocalization["Renamed category"] + ": " + SelectedCategory + " to " + newCategoryName);
SelectedCategory = newCategoryName;
await FetchTemplates();
RenameModal?.Hide();
RenameModal?.Close();
}
await RefreshComponents();

Expand Down Expand Up @@ -253,7 +256,7 @@
}
}
var result = await Context.SaveChangesAsync();
RestoreModal?.Hide();
RestoreModal?.Close();
SnackBarService.Success(AppLocalization["Template(s) restored"]);
}
}
4 changes: 2 additions & 2 deletions BLAZAM/Pages/Groups/ViewGroup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@


<AppModal Title=@AppLocalization["Assign To"] @ref=@AssignToModal>
<AssignToModalContent OnGroupMembershipChange=@((change)=>{AssignToModal?.Hide(); InvokeAsync(StateHasChanged);}) DirectoryModel="Group" />
<AssignToModalContent OnGroupMembershipChange=@((change)=>{AssignToModal?.Close(); InvokeAsync(StateHasChanged);}) DirectoryModel="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Add Members"] @ref=@AssignMemberModal>
<AddMemberModalContent ModelChanged=@((change)=>{AssignMemberModal?.Hide();InvokeAsync(StateHasChanged);}) Group="Group" />
<AddMemberModalContent ModelChanged=@((change)=>{AssignMemberModal?.Close();InvokeAsync(StateHasChanged);}) Group="Group" />
</AppModal>
<AppModal Title=@AppLocalization["Move To"] @ref=@MoveToModal>
@if (MoveToModal?.IsShown == true)
Expand Down
89 changes: 70 additions & 19 deletions BLAZAM/Pages/Users/ConfirmNewUser.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@using BLAZAM.EmailMessage.Email
@using System.Security
@inherits DirectoryModelComponent
@inject IJSRuntime JSRuntime
<AppPageTitle>Confirm User Creation</AppPageTitle>
Expand Down Expand Up @@ -54,12 +56,12 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)
}

@if (InDirectoryTemplate(ActiveDirectoryFields.HomePhone) ||
InDirectoryTemplate(ActiveDirectoryFields.StreetAddress) ||
InDirectoryTemplate(ActiveDirectoryFields.POBox) ||
InDirectoryTemplate(ActiveDirectoryFields.City) ||
InDirectoryTemplate(ActiveDirectoryFields.State) ||
InDirectoryTemplate(ActiveDirectoryFields.PostalCode)
)
InDirectoryTemplate(ActiveDirectoryFields.StreetAddress) ||
InDirectoryTemplate(ActiveDirectoryFields.POBox) ||
InDirectoryTemplate(ActiveDirectoryFields.City) ||
InDirectoryTemplate(ActiveDirectoryFields.State) ||
InDirectoryTemplate(ActiveDirectoryFields.PostalCode)
)
{
<Section Title=@AppLocalization["Contact Info"]>

Expand Down Expand Up @@ -98,10 +100,10 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)
<MudTextField Label="@AppLocalization["Site"]" @bind-Value="@User.Site" Disabled=true />
}
@if (InDirectoryTemplate(ActiveDirectoryFields.HomeDirectory) ||
InDirectoryTemplate(ActiveDirectoryFields.HomeDrive) ||
InDirectoryTemplate(ActiveDirectoryFields.ScriptPath) ||
InDirectoryTemplate(ActiveDirectoryFields.ProfilePath)
)
InDirectoryTemplate(ActiveDirectoryFields.HomeDrive) ||
InDirectoryTemplate(ActiveDirectoryFields.ScriptPath) ||
InDirectoryTemplate(ActiveDirectoryFields.ProfilePath)
)
{
<Section Title=@AppLocalization["Profile"]>
@if (InDirectoryTemplate(ActiveDirectoryFields.HomeDirectory))
Expand Down Expand Up @@ -157,17 +159,24 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)
{
<MudButton Disabled=@disableCreateUserButton Color="Color.Success" OnClick="ConfirmUser">Create User</MudButton>

}else{
}
else
{
<MudButton Color="Color.Primary" OnClick="@(()=>{Nav.NavigateTo(User.SearchUri);})">Go To User</MudButton>
<MudButton Color="Color.Success" OnClick="@(()=>{Nav.NavigateTo("/create/user");})">Create Another</MudButton>

}
<MudButton StartIcon="@Icons.Material.Filled.Print" Color="Color.Info" OnClick="Print">Print</MudButton>
<MudButton Color="Color.Success" OnClick="@(()=>{SendWelcomeModal?.Show();})">Test</MudButton>

<AppModal @ref=SendWelcomeModal Title="@AppLocalization["Send login credentials"]">
<SendNewUserWelcomeToModalContent OnSubmitEmail="SendWelcomeEmail" />
</AppModal>
@code {
[Parameter]
public DirectoryTemplate? DirectoryTemplate { get; set; }

AppModal? SendWelcomeModal;
[Parameter]
public EventCallback<IADUser> Confirmed { get; set; }
/// <summary>
Expand All @@ -181,7 +190,9 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)
return DirectoryTemplate?.FieldValues.Any(f => f.Field?.FieldName == field.FieldName) == true;
}
bool confirmed = false;
bool disableCreateUserButton=false;
bool disableCreateUserButton = false;
SecureString? _userPassword;
string? _username;
/// <summary>
/// Triggered when the user confirms the creation of this
/// Active Directory User
Expand All @@ -192,22 +203,24 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)

try
{
disableCreateUserButton =true;
disableCreateUserButton = true;
await InvokeAsync(StateHasChanged);
IJob createUserJob = new Job(AppLocalization["Create User"]);
createUserJob.StopOnFailedStep = true;
createUserJob.ShowJobDetailsDialog(MessageService);
_username = User.SamAccountName;
_userPassword = User.NewPassword;
var result = await User.CommitChangesAsync(createUserJob);

disableCreateUserButton = false;
await InvokeAsync(StateHasChanged);
if (result.FailedSteps.Count == 0)
{
var newUser = Directory.Users.FindUsersByContainerName(User.CanonicalName, false, true);
if (newUser != null)
{
User = newUser;
}
// var newUser = Directory.Users.FindUsersByContainerName(User.CanonicalName, false, true);
// if (newUser != null)
// {
// User = newUser;
// }
SnackBarService.Success("User has been created");
confirmed = true;
await Confirmed.InvokeAsync();
Expand All @@ -216,6 +229,27 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)
}
await AuditLogger.User.Created(User);

try
{
if (DirectoryTemplate.EffectiveSendWelcomeEmail == true)
{
if (DirectoryTemplate.EffectiveAskForAlternateEmail == true || User.Email.IsNullOrEmpty())
{
SendWelcomeModal?.Show();
}
else
{
SendWelcomeEmail(User.Email);
}

}
}
catch
{

}


}
catch (ApplicationException ex)
{
Expand All @@ -224,7 +258,24 @@ InDirectoryTemplate(ActiveDirectoryFields.PhysicalDeliveryOffice)


}

async Task SendWelcomeEmail(string to)
{
try{
NewUserWelcomeEmailMessage message = new NewUserWelcomeEmailMessage();
message.Domain = User.Directory.ConnectionSettings.FQDN;
message.Username = _username;
message.Password = _userPassword;
var html = message.Render();
EmailService.SendMessage(AppLocalization["New Account Details"], message,to);
SnackBarService.Info(AppLocalization["Welcome Email Sent to "] + to);
SendWelcomeModal.Close();
}catch (Exception ex)
{
Loggers.SystemLogger.Error("Error sending welcome email {@Error}", ex);
SnackBarService.Error(ex.Message);
}
//emailPreview = EmailService.PrepareHTMLForEmail(html);
}
async Task Print()
{
await JSRuntime.InvokeVoidAsync("printPage", null);
Expand Down
6 changes: 3 additions & 3 deletions BLAZAM/Pages/Users/CreateUser.razor
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ newUser?.StagePasswordChange(customConfirmPassword.ToSecureString());
{
LoadingData = true;
await InvokeAsync(StateHasChanged);
var ou = Directory.OUs.FindOuByString(SelectedTemplate.ParentOU).FirstOrDefault();
var ou = Directory.OUs.FindOuByString(SelectedTemplate.EffectiveParentOU).FirstOrDefault();
if (ou == null) throw new ApplicationException("OU could not be found for new user");
newUser = ou.CreateUser(SelectedTemplate.GenerateDisplayName(newUserName));

Expand All @@ -283,7 +283,7 @@ newUser?.StagePasswordChange(customConfirmPassword.ToSecureString());
if (!newUserName.Surname.IsNullOrEmpty())
newUser.Surname = newUserName.Surname;

foreach (var fieldValue in SelectedTemplate.InheritedFieldValues)
foreach (var fieldValue in SelectedTemplate.EffectiveFieldValues)
{
try
{
Expand Down Expand Up @@ -331,7 +331,7 @@ newUser?.StagePasswordChange(customConfirmPassword.ToSecureString());

Loggers.ActiveDirectryLogger.Error("Error while creating template user {@Error}", ex);

SnackBarService.Error(AppLocalization["An error has occurred while trying to create the template user"]);
SnackBarService.Error(AppLocalization["An error has occurred while trying to create the template user: "] + ex.Message);
}
LoadingData = false;

Expand Down
Loading

0 comments on commit 32e84c8

Please sign in to comment.