Browse Source

bugfix

pull/3841/head
timlai 11 months ago
parent
commit
81ec84c4ae
  1. 19
      src/SSCMS.Core/Repositories/AdministratorRepository.cs
  2. 2
      src/SSCMS.Core/Utils/Serialization/BackupUtility.cs
  3. 33
      src/SSCMS.Core/Utils/Serialization/ExportObject.cs
  4. 2
      src/SSCMS.Web/Controllers/Admin/Cms/Channels/ChannelsController.Export.cs
  5. 2
      src/SSCMS.Web/Controllers/Admin/Cms/Channels/ChannelsController.cs
  6. 2
      src/SSCMS.Web/Pages/shared/_Layout.cshtml
  7. 2
      src/SSCMS.Web/Pages/shared/_LayoutHome.cshtml
  8. 2
      src/SSCMS.Web/Pages/ss-admin/cms/channels.cshtml
  9. 6
      src/SSCMS.Web/wwwroot/sitefiles/assets/js/admin/cms/channels.js

19
src/SSCMS.Core/Repositories/AdministratorRepository.cs

@ -565,8 +565,7 @@ namespace SSCMS.Core.Repositories
return (null, userName, errorMessage);
}
return CheckPassword(password, isPasswordMd5, administrator.Password,
administrator.PasswordFormat, administrator.PasswordSalt)
return await CheckPasswordByAdminIdAsync(administrator.Id, password, isPasswordMd5)
? (administrator, userName, string.Empty)
: (null, userName, "账号或密码错误");
}
@ -632,9 +631,21 @@ namespace SSCMS.Core.Repositories
return retVal;
}
private static bool CheckPassword(string password, bool isPasswordMd5, string dbPassword, PasswordFormat passwordFormat, string passwordSalt)
private async Task<bool> CheckPasswordByAdminIdAsync(int adminId, string password, bool isPasswordMd5)
{
var decodePassword = DecodePassword(dbPassword, passwordFormat, passwordSalt);
var dbAdmin = await _repository.GetAsync<Administrator>(Q
.Select(nameof(Administrator.Password))
.Select(nameof(Administrator.PasswordFormat))
.Select(nameof(Administrator.PasswordSalt))
.Where(nameof(Administrator.Id), adminId)
);
if (dbAdmin == null || string.IsNullOrEmpty(dbAdmin.Password) || string.IsNullOrEmpty(dbAdmin.PasswordSalt))
{
return false;
}
var decodePassword = DecodePassword(dbAdmin.Password, dbAdmin.PasswordFormat, dbAdmin.PasswordSalt);
if (isPasswordMd5)
{
return password == AuthUtils.Md5ByString(decodePassword);

2
src/SSCMS.Core/Utils/Serialization/BackupUtility.cs

@ -25,7 +25,7 @@ namespace SSCMS.Core.Utils.Serialization
var channelIdList = await databaseManager.ChannelRepository.GetChannelIdsAsync(site.Id, site.Id, ScopeType.Children);
await exportObject.ExportChannelsAsync(channelIdList, filePath, true);
await exportObject.ExportChannelsAsync(channelIdList, filePath, true, true, true);
}
public static async Task BackupFilesAsync(IPathManager pathManager, IDatabaseManager databaseManager, CacheUtils caching, Site site, string filePath)

33
src/SSCMS.Core/Utils/Serialization/ExportObject.cs

@ -268,13 +268,13 @@ namespace SSCMS.Core.Utils.Serialization
XmlUtils.SaveAsXml(siteTemplate, xmlPath);
}
public async Task<string> ExportChannelsAsync(List<int> channelIdList, bool isContents)
public async Task<string> ExportChannelsAsync(List<int> channelIdList, bool isContents, bool isFileImages, bool isFileAttaches)
{
var filePath = _pathManager.GetTemporaryFilesPath(BackupType.ChannelsAndContents.GetValue() + ".zip");
return await ExportChannelsAsync(channelIdList, filePath, isContents);
return await ExportChannelsAsync(channelIdList, filePath, isContents, isFileImages, isFileAttaches);
}
public async Task<string> ExportChannelsAsync(List<int> channelIdList, string filePath, bool isContents)
public async Task<string> ExportChannelsAsync(List<int> channelIdList, string filePath, bool isContents, bool isFileImages, bool isFileAttaches)
{
var siteContentDirectoryPath = PathUtils.Combine(DirectoryUtils.GetDirectoryPath(filePath), PathUtils.GetFileNameWithoutExtension(filePath));
@ -302,17 +302,26 @@ namespace SSCMS.Core.Utils.Serialization
if (isContents)
{
var imageUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.ImageUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(imageUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.ImageUploadDirectoryName), imageUploadDirectoryPath);
if (isFileImages)
{
var imageUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.ImageUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(imageUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.ImageUploadDirectoryName), imageUploadDirectoryPath);
}
if (isFileAttaches)
{
var audioUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.AudioUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(audioUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.AudioUploadDirectoryName), audioUploadDirectoryPath);
var videoUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.VideoUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(videoUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.VideoUploadDirectoryName), videoUploadDirectoryPath);
var videoUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.VideoUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(videoUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.VideoUploadDirectoryName), videoUploadDirectoryPath);
var fileUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.FileUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(fileUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.FileUploadDirectoryName), fileUploadDirectoryPath);
var fileUploadDirectoryPath = PathUtils.Combine(siteContentDirectoryPath, _site.FileUploadDirectoryName);
DirectoryUtils.DeleteDirectoryIfExists(fileUploadDirectoryPath);
DirectoryUtils.Copy(PathUtils.Combine(sitePath, _site.FileUploadDirectoryName), fileUploadDirectoryPath);
}
}
AtomFeed feed = AtomUtility.GetEmptyFeed();

2
src/SSCMS.Web/Controllers/Admin/Cms/Channels/ChannelsController.Export.cs

@ -23,7 +23,7 @@ namespace SSCMS.Web.Controllers.Admin.Cms.Channels
var caching = new CacheUtils(_cacheManager);
var exportObject = new ExportObject(_pathManager, _databaseManager, caching, site);
var fileName = await exportObject.ExportChannelsAsync(request.ChannelIds, request.IsContents);
var fileName = await exportObject.ExportChannelsAsync(request.ChannelIds, request.IsContents, request.IsFileImages, request.IsFileAttaches);
var filePath = _pathManager.GetTemporaryFilesPath(fileName);
var url = _pathManager.GetDownloadApiUrl(filePath);

2
src/SSCMS.Web/Controllers/Admin/Cms/Channels/ChannelsController.cs

@ -154,6 +154,8 @@ namespace SSCMS.Web.Controllers.Admin.Cms.Channels
{
public List<int> ChannelIds { get; set; }
public bool IsContents { get; set; }
public bool IsFileImages { get; set; }
public bool IsFileAttaches { get; set; }
}
public class DeleteRequest : SiteRequest

2
src/SSCMS.Web/Pages/shared/_Layout.cshtml

@ -7,6 +7,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="preload" as="font" type="font/woff" href="/sitefiles/assets/lib/elementui/themechalk/fonts/element-icons.woff" crossorigin="anonymous">
<link rel="preload" as="font" type="font/ttf" href="/sitefiles/assets/fonts/ionicons.ttf?v=2.0.0" crossorigin="anonymous">
<link href="/sitefiles/assets/css/font-awesome-4.7.0.min.css" rel="stylesheet" type="text/css" />
<link href="/sitefiles/assets/css/ionicons-2.0.0.min.css" rel="stylesheet" type="text/css" />
<link href="/sitefiles/assets/lib/elementui/themechalk/index.css" rel="stylesheet" type="text/css" />

2
src/SSCMS.Web/Pages/shared/_LayoutHome.cshtml

@ -8,6 +8,8 @@
<meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="/sitefiles/assets/images/favicon.png" rel="icon" type="image/png">
<link rel="preload" as="font" type="font/woff" href="/sitefiles/assets/lib/elementui/themechalk/fonts/element-icons.woff" crossorigin="anonymous">
<link rel="preload" as="font" type="font/ttf" href="/sitefiles/assets/fonts/ionicons.ttf?v=2.0.0" crossorigin="anonymous">
<link href="/sitefiles/assets/css/font-awesome-4.7.0.min.css" rel="stylesheet" type="text/css" />
<link href="/sitefiles/assets/css/ionicons-2.0.0.min.css" rel="stylesheet" type="text/css" />
<link href="/sitefiles/assets/lib/elementui/default/index.css" rel="stylesheet" type="text/css" />

2
src/SSCMS.Web/Pages/ss-admin/cms/channels.cshtml

@ -429,6 +429,8 @@
<el-form-item>
<el-checkbox label="同时导出内容" v-model="exportForm.isContents"></el-checkbox>
<el-checkbox label="同时导出图片文件" v-if="exportForm.isContents" v-model="exportForm.isFileImages"></el-checkbox>
<el-checkbox label="同时导出附件文件" v-if="exportForm.isContents" v-model="exportForm.isFileAttaches"></el-checkbox>
</el-form-item>
<el-divider></el-divider>

6
src/SSCMS.Web/wwwroot/sitefiles/assets/js/admin/cms/channels.js

@ -209,6 +209,8 @@ var methods = {
siteId: this.siteId,
channelIds: this.channelIds,
isContents: this.exportForm.isContents,
isFileImages: this.exportForm.isFileImages,
isFileAttaches: this.exportForm.isFileAttaches,
}).then(function (response) {
var res = response.data;
@ -607,7 +609,9 @@ var methods = {
btnExportClick: function() {
this.exportForm = {
isContents: true
isContents: true,
isFileImages: false,
isFileAttaches: false,
};
this.exportPanel = true;
},

Loading…
Cancel
Save