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

fix #3231 - validate module description #3271

Merged
merged 1 commit into from
Sep 20, 2023
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
28 changes: 22 additions & 6 deletions Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@

protected override void OnInitialized()
{
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
if (!NavigationManager.BaseUri.Contains("localhost:"))
{
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
}
}

protected override async Task OnParametersSetAsync()
Expand All @@ -115,11 +118,18 @@
{
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
{
var template = _templates.FirstOrDefault(item => item.Name == _template);
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference, ModuleDefinitionName = template.Namespace };
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
GetLocation();
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
if (IsValidXML(_description))
{
var template = _templates.FirstOrDefault(item => item.Name == _template);
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference, ModuleDefinitionName = template.Namespace };
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
GetLocation();
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
}
else
{
AddModuleMessage(Localizer["Message.Require.ValidDescription"], MessageType.Warning);
}
}
else
{
Expand All @@ -143,6 +153,12 @@
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && !name.ToLower().Contains("oqtane") && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
}

private bool IsValidXML(string description)
{
// must contain letters, digits, or spaces
return Regex.IsMatch(description, "^[A-Za-z0-9 ]+$");
}

private void TemplateChanged(ChangeEventArgs e)
{
_template = (string)e.Value;
Expand Down
5 changes: 4 additions & 1 deletion Oqtane.Client/Modules/Admin/Themes/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@

protected override void OnInitialized()
{
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
if (!NavigationManager.BaseUri.Contains("localhost:"))
{
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
}
}

protected override async Task OnParametersSetAsync()
Expand Down
177 changes: 0 additions & 177 deletions Oqtane.Client/Resources/Modules/Admin/ModuleCreator/Index.resx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<data name="Message.Require.ValidName" xml:space="preserve">
<value>You Must Provide A Valid Owner Name And Module Name ( ie. No Punctuation Or Spaces And The Values Cannot Be The Same ) And Choose A Template</value>
</data>
<data name="Message.Require.ValidDescription" xml:space="preserve">
<value>You Must Provide A Valid Description (ie. No Punctuation)</value>
</data>
<data name="OwnerName.HelpText" xml:space="preserve">
<value>Enter the name of the organization who is developing this module. It should not contain spaces or punctuation.</value>
</data>
Expand Down
2 changes: 0 additions & 2 deletions Oqtane.Client/Themes/Controls/Theme/LoginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class LoginBase : ThemeControlBase
[Inject] public IJSRuntime jsRuntime { get; set; }
[Inject] public IServiceProvider ServiceProvider { get; set; }

private bool _allowsitelogin = true;

protected void LoginUser()
{
Route route = new Route(PageState.Uri.AbsoluteUri, PageState.Alias.Path);
Expand Down