+
Skip to content
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
1 change: 1 addition & 0 deletions src/Mix.Cms.Api/Controllers/v1/ApiAccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public async Task<ActionResult<RepositoryResponse<AccessTokenViewModel>>> Regist
var createResult = await _userManager.CreateAsync(user, password: model.Password).ConfigureAwait(false);
if (createResult.Succeeded)
{
await _userManager.AddToRoleAsync(user, MixDefaultRoles.Guest);
var saveData = await Mix.Cms.Lib.ViewModels.MixDatabaseDatas.Helper.SaveObjAsync(
MixDatabaseNames.SYSTEM_USER_DATA, model.UserData, user.UserName, MixDatabaseParentType.User);
result.IsSucceed = saveData.IsSucceed;
Expand Down
18 changes: 1 addition & 17 deletions src/Mix.Cms.Api/Controllers/v1/ApiInitCmsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private async Task<RepositoryResponse<bool>> InitStep1Async(InitCmsViewModel mod

if (result.IsSucceed)
{
await InitRolesAsync();
await InitCmsService.InitRolesAsync(_roleManager);
result.IsSucceed = true;
MixService.LoadFromDatabase();
MixService.SetConfig<string>("DefaultCulture", model.Culture.Specificulture);
Expand All @@ -288,22 +288,6 @@ private async Task<RepositoryResponse<bool>> InitStep1Async(InitCmsViewModel mod
return result;
}

private async Task<bool> InitRolesAsync()
{
bool isSucceed = true;
var getRoles = await RoleViewModel.Repository.GetModelListAsync();
if (getRoles.IsSucceed && getRoles.Data.Count == 0)
{
var saveResult = await _roleManager.CreateAsync(new IdentityRole()
{
Id = Guid.NewGuid().ToString(),
Name = MixDefaultRoles.SuperAdmin
});
isSucceed = saveResult.Succeeded;
}
return isSucceed;
}

#endregion Helpers
}
}
1 change: 1 addition & 0 deletions src/Mix.Cms.Lib/Constants/MixDefaultRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public class MixDefaultRoles
{
public const string SuperAdmin = "SuperAdmin";
public const string Admin = "Admin";
public const string Guest = "Guest";
}
}
25 changes: 23 additions & 2 deletions src/Mix.Cms.Lib/Services/InitCmsService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Mix.Cms.Lib.Constants;
using Mix.Cms.Lib.Enums;
Expand All @@ -25,6 +26,26 @@ public InitCmsService()
{
}

public static async Task InitRolesAsync(RoleManager<IdentityRole> _roleManager)
{
await CreateRoleIfNotExist(_roleManager, MixDefaultRoles.SuperAdmin);
await CreateRoleIfNotExist(_roleManager, MixDefaultRoles.Admin);
await CreateRoleIfNotExist(_roleManager, MixDefaultRoles.Guest);
}

private static async Task CreateRoleIfNotExist(RoleManager<IdentityRole> _roleManager, string role)
{
var isExist = await _roleManager.RoleExistsAsync(role);
if (!isExist)
{
await _roleManager.CreateAsync(new IdentityRole()
{
Id = Guid.NewGuid().ToString(),
Name = role
});
}
}

/// <summary>
/// Step 1
/// - Init Culture
Expand Down Expand Up @@ -55,7 +76,7 @@ public static async Task<RepositoryResponse<bool>> InitCms(string siteName, Init
if (pendingMigration == 0)
{
return await InitSiteData(siteName, culture);
}
}
}
return result;
}
Expand Down
156 changes: 156 additions & 0 deletions src/Mix.Cms.Web/MixContent/data/sys_databases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,162 @@
"id": 13,
"ReferenceId": null,
"type": "System",
"title": "Permission Endpoint",
"name": "sys_permission_endpoint",
"description": null,
"formTemplate": null,
"createdBy": "tinku",
"createdDateTime": "2021-06-18T01:25:48",
"modifiedBy": null,
"lastModified": null,
"priority": 0,
"status": "Published",
"specificulture": null,
"columns": [
{
"id": 90,
"specificulture": null,
"mixDatabaseId": 13,
"mixDatabaseName": "sys_permission_endpoint",
"configurations": "{\"maxLength\":null,\"belongTo\":null,\"optionsConfigurationName\":null,\"upload\":{\"arrayAccepts\":[],\"accepts\":\"\",\"width\":null,\"height\":null,\"isCrop\":false}}",
"referenceId": null,
"regex": null,
"isRegex": false,
"title": "TItle",
"dataType": "Custom",
"defaultValue": null,
"strOptions": "[]",
"options": [],
"name": "title",
"isRequire": false,
"isEncrypt": false,
"isSelect": false,
"isUnique": false,
"isMultiple": false,
"createdBy": null,
"createdDateTime": "2021-06-18T01:25:49",
"modifiedBy": null,
"lastModified": null,
"priority": 1,
"status": "Published",
"columnConfigurations": {
"maxLength": null,
"belongTo": null,
"optionsConfigurationName": null,
"upload": {
"arrayAccepts": [],
"accepts": "",
"width": null,
"height": null,
"isCrop": false
}
}
},
{
"id": 91,
"specificulture": null,
"mixDatabaseId": 13,
"mixDatabaseName": "sys_permission_endpoint",
"configurations": "{\"maxLength\":null,\"belongTo\":null,\"optionsConfigurationName\":null,\"upload\":{\"arrayAccepts\":[],\"accepts\":\"\",\"width\":null,\"height\":null,\"isCrop\":false}}",
"referenceId": null,
"regex": null,
"isRegex": false,
"title": "Endpoint",
"dataType": "Custom",
"defaultValue": null,
"strOptions": "[]",
"options": [],
"name": "endpoint",
"isRequire": false,
"isEncrypt": false,
"isSelect": false,
"isUnique": false,
"isMultiple": false,
"createdBy": null,
"createdDateTime": "2021-06-18T01:25:49",
"modifiedBy": null,
"lastModified": null,
"priority": 2,
"status": "Published",
"columnConfigurations": {
"maxLength": null,
"belongTo": null,
"optionsConfigurationName": null,
"upload": {
"arrayAccepts": [],
"accepts": "",
"width": null,
"height": null,
"isCrop": false
}
}
},
{
"id": 92,
"specificulture": null,
"mixDatabaseId": 13,
"mixDatabaseName": "sys_permission_endpoint",
"configurations": "{\"maxLength\":null,\"belongTo\":null,\"optionsConfigurationName\":null,\"upload\":{\"arrayAccepts\":[],\"accepts\":\"\",\"width\":null,\"height\":null,\"isCrop\":false}}",
"referenceId": null,
"regex": null,
"isRegex": false,
"title": "Method",
"dataType": "Text",
"defaultValue": null,
"strOptions": "[\r\n {\r\n \"value\": \"GET\",\r\n \"dataType\": 7\r\n },\r\n {\r\n \"value\": \"POST\",\r\n \"dataType\": 7\r\n },\r\n {\r\n \"value\": \"PUT\",\r\n \"dataType\": 7\r\n },\r\n {\r\n \"value\": \"PATCH\",\r\n \"dataType\": 7\r\n },\r\n {\r\n \"value\": \"DELETE\",\r\n \"dataType\": 7\r\n }\r\n]",
"options": [
{
"value": "GET",
"dataType": 7
},
{
"value": "POST",
"dataType": 7
},
{
"value": "PUT",
"dataType": 7
},
{
"value": "PATCH",
"dataType": 7
},
{
"value": "DELETE",
"dataType": 7
}
],
"name": "method",
"isRequire": false,
"isEncrypt": false,
"isSelect": true,
"isUnique": false,
"isMultiple": false,
"createdBy": null,
"createdDateTime": "2021-06-18T01:25:49",
"modifiedBy": null,
"lastModified": null,
"priority": 3,
"status": "Published",
"columnConfigurations": {
"maxLength": null,
"belongTo": null,
"optionsConfigurationName": null,
"upload": {
"arrayAccepts": [],
"accepts": "",
"width": null,
"height": null,
"isCrop": false
}
}
}
]
},
{
"id": 18,
"ReferenceId": null,
"type": "System",
"title": "Mix Edm",
"name": "sys_mix_edm",
"description": null,
Expand Down
6 changes: 6 additions & 0 deletions src/Mix.Cms.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -95,6 +96,7 @@ public void ConfigureServices(IServiceCollection services)
//services.AddMixGprc();
services.AddMixScheduler(Configuration);

services.AddScoped<InitCmsService>();
services.AddSingleton<MixCacheService>();
services.AddMixAuthorize<MixDbContext>(MixService.Instance.MixAuthentications);
services.AddScoped<MixIdentityService>();
Expand Down Expand Up @@ -182,6 +184,7 @@ private void VerifyInitData(IServiceCollection services)
{
if (!ctx.MixDatabase.Any(m => m.Name == db.Name))
{
db.Id = 0;
db.SaveModel(true, ctx, transaction);
}
}
Expand All @@ -192,6 +195,9 @@ private void VerifyInitData(IServiceCollection services)
{
cacheCtx.Database.Migrate();
}
var serviceProvider = services.BuildServiceProvider();
var _roleManager = serviceProvider.GetService<RoleManager<IdentityRole>>();
InitCmsService.InitRolesAsync(_roleManager).GetAwaiter();
}

// Mix: Check if require ssl
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="btn-toolbar d-flex card-body" role="group" aria-label=""><div class="btn-group me-2"><button type="button" ng-click="$ctrl.back()" class="btn btn-light me-1"><i class="fa fa-chevron-left"></i></button></div><div class="btn-group flex-fill me-3"><button id="btnToSubmit" type="submit" class="btn btn-primary ms-auto" ng-if="!$ctrl.primaryUrl" ng-click="$ctrl.submit($event)"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-device-floppy" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2"/><circle cx="12" cy="14" r="2"/><polyline points="14 4 14 8 8 8 8 4"/></svg> <span>Save</span></button></div><div class="btn-group me-2"><div class="dropdown float-lg-end ms-auto pe-1"><a href="javascript:;" class="cursor-pointer" id="dropdownTable2" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-h text-secondary" aria-hidden="true"></i></a><ul class="dropdown-menu px-2 py-3 ms-sm-n4 ms-n5" aria-labelledby="dropdownTable2" style=""><li><a ng-if="$ctrl.previewUrl" target="_blank" href="{{$ctrl.previewUrl}}" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-eye-check" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><circle cx="12" cy="12" r="2"/><path d="M12 19c-4 0 -7.333 -2.333 -10 -7c2.667 -4.667 6 -7 10 -7s7.333 2.333 10 7c-.42 .736 -.858 1.414 -1.311 2.033"/><path d="M15 19l2 2l4 -4"/></svg> <span>Preview</span></a></li><li><a ng-if="$ctrl.contentUrl" href="{{$ctrl.contentUrl}}" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-notes" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><rect x="5" y="3" width="14" height="18" rx="2"/><line x1="9" y1="7" x2="15" y2="7"/><line x1="9" y1="11" x2="15" y2="11"/><line x1="9" y1="15" x2="13" y2="15"/></svg> <span>Data List</span></a></li><li><button type="button" ng-click="$ctrl.clearCache()" ng-if="$ctrl.onClearCache" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-refresh" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"/><path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg> <span>Clear Cache</span></button></li></ul></div></div></div>
<div class="btn-toolbar d-flex card-body" role="group" aria-label=""><div class="btn-group me-2"><button type="button" ng-click="$ctrl.back()" class="btn btn-light me-1"><i class="fa fa-chevron-left"></i></button></div><div class="btn-group flex-fill me-3"><button id="btnToSubmit" type="submit" class="btn btn-primary ms-auto" ng-click="$ctrl.submit($event)"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-device-floppy" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2"/><circle cx="12" cy="14" r="2"/><polyline points="14 4 14 8 8 8 8 4"/></svg> <span>Save</span></button></div><div class="btn-group me-2"><div class="dropdown float-lg-end ms-auto pe-1"><a href="javascript:;" class="cursor-pointer" id="dropdownTable2" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-h text-secondary" aria-hidden="true"></i></a><ul class="dropdown-menu px-2 py-3 ms-sm-n4 ms-n5" aria-labelledby="dropdownTable2" style=""><li><a ng-if="$ctrl.previewUrl" target="_blank" href="{{$ctrl.previewUrl}}" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-eye-check" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><circle cx="12" cy="12" r="2"/><path d="M12 19c-4 0 -7.333 -2.333 -10 -7c2.667 -4.667 6 -7 10 -7s7.333 2.333 10 7c-.42 .736 -.858 1.414 -1.311 2.033"/><path d="M15 19l2 2l4 -4"/></svg> <span>Preview</span></a></li><li><a ng-if="$ctrl.contentUrl" href="{{$ctrl.contentUrl}}" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-notes" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><rect x="5" y="3" width="14" height="18" rx="2"/><line x1="9" y1="7" x2="15" y2="7"/><line x1="9" y1="11" x2="15" y2="11"/><line x1="9" y1="15" x2="13" y2="15"/></svg> <span>Data List</span></a></li><li><button type="button" ng-click="$ctrl.clearCache()" ng-if="$ctrl.onClearCache" class="dropdown-item border-radius-md"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-refresh" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"/><path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg> <span>Clear Cache</span></button></li></ul></div></div></div>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="card mb-4 ga-container" ng-init="$ctrl.init()"><div class="card-header"><h6>Contributers</h6></div><div class="card-body"><a ng-repeat="item in $ctrl.items" href="https://github.com/mixcore/mix.core/graphs/contributors" class="me-1" target="_blank" ng-if="item.login != 'ImgBotApp' && item.login != 'mergedroid' && item.login != 'dependabot[bot]' && item.login != 'depfu[bot]' && item.login != 'gitter-badger' && item.login != 'fossabot' && item.login != 'whitesource-bolt-for-github[bot]'"><img ng-src="{{item.avatar_url}}" alt="{{item.login}}" title="{{item.login}}" class="md-avatar img-thumbnail rounded-circle" style="vertical-align: middle; width: 40px; height: 40px"></a></div></div>
<div class="card mb-4 ga-container" ng-init="$ctrl.init()"><div class="card-header"><h6>Contributers</h6></div><div class="card-body"><a ng-repeat="item in $ctrl.items" href="{{item.html_url}}" target="_blank" ng-if="item.login != 'ImgBotApp' && item.login != 'mergedroid' && item.login != 'dependabot[bot]' && item.login != 'depfu[bot]' && item.login != 'gitter-badger' && item.login != 'fossabot' && item.login != 'whitesource-bolt-for-github[bot]'"><img ng-src="{{item.avatar_url}}" alt="{{item.login}}" class="md-avatar img-thumbnail rounded-circle" style="vertical-align: middle; width: 40px; height: 40px"></a></div></div>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="card mb-4 ga-container" ng-init="$ctrl.init()"><div class="card-header"><h6>Latest Releases</h6></div><div class="card-body"><div><ul class="list-group list-group-flush" ng-repeat="item in $ctrl.items|limitTo:3"><li class="list-group-item d-flex justify-content-between align-items-start"><div class="ms-2 me-auto"><div class="fw-bold"><a href="{{item.html_url}}" target="_blank" class="btn-link strong"><strong>{{item.tag_name}}</strong></a></div><span class="small">{{item.published_at | date:'short'}}</span></div><a class="btn btn-sm btn-light" href="{{item.zipball_url}}" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-download" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentcolor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"/><polyline points="7 11 12 16 17 11"/><line x1="12" y1="4" x2="12" y2="16"/></svg></a></li></ul></div></div></div>
<div class="card mb-4 ga-container" ng-init="$ctrl.init()"><div class="card-header"><h6>Latest Releases</h6></div><div class="card-body"><div><ul class="list-group list-group-flush" ng-repeat="item in $ctrl.items|limitTo:4"><li class="list-group-item d-flex justify-content-between align-items-start"><div class="ms-2 me-auto"><div class="fw-bold"><a href="{{item.html_url}}" target="_blank" class="btn-link strong"><strong>{{item.tag_name}}</strong></a></div><span class="small">{{item.published_at | date:'short'}}</span></div><a class="btn btn-sm btn-light" href="{{item.zipball_url}}" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-download" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentcolor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"/><polyline points="7 11 12 16 17 11"/><line x1="12" y1="4" x2="12" y2="16"/></svg></a></li></ul></div></div></div>
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载