mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Web.Security;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Users.Models;
|
||||
|
||||
namespace Orchard.Users.Drivers {
|
||||
public class UserPartDriver : ContentPartDriver<UserPart> {
|
||||
|
||||
protected override void Importing(UserPart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||
part.Record.Email = context.Attribute(part.PartDefinition.Name, "Email");
|
||||
part.Record.EmailChallengeToken = context.Attribute(part.PartDefinition.Name, "EmailChallengeToken");
|
||||
part.Record.EmailStatus = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "EmailStatus"));
|
||||
part.Record.HashAlgorithm = context.Attribute(part.PartDefinition.Name, "HashAlgorithm");
|
||||
part.Record.NormalizedUserName = context.Attribute(part.PartDefinition.Name, "NormalizedUserName");
|
||||
part.Record.Password = context.Attribute(part.PartDefinition.Name, "Password");
|
||||
part.Record.PasswordFormat = (MembershipPasswordFormat)Enum.Parse(typeof(MembershipPasswordFormat), context.Attribute(part.PartDefinition.Name, "PasswordFormat"));
|
||||
part.Record.PasswordSalt = context.Attribute(part.PartDefinition.Name, "PasswordSalt");
|
||||
part.Record.RegistrationStatus = (UserStatus)Enum.Parse(typeof(UserStatus), context.Attribute(part.PartDefinition.Name, "RegistrationStatus"));
|
||||
part.Record.UserName = context.Attribute(part.PartDefinition.Name, "UserName");
|
||||
}
|
||||
|
||||
protected override void Exporting(UserPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Email", part.Record.Email);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("EmailChallengeToken", part.Record.EmailChallengeToken);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("EmailStatus", part.Record.EmailStatus);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("HashAlgorithm", part.Record.HashAlgorithm);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("NormalizedUserName", part.Record.NormalizedUserName);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Password", part.Record.Password);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("PasswordFormat", part.Record.PasswordFormat);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("PasswordSalt", part.Record.PasswordSalt);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("RegistrationStatus", part.Record.RegistrationStatus);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("UserName", part.Record.UserName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,6 @@
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Data.Migration;
|
||||
using Orchard.Core.Contents.Extensions;
|
||||
|
||||
namespace Orchard.Users {
|
||||
public class UsersDataMigration : DataMigrationImpl {
|
||||
@@ -34,5 +36,11 @@ namespace Orchard.Users {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int UpdateFrom1() {
|
||||
ContentDefinitionManager.AlterTypeDefinition("User", cfg => cfg.Creatable(false));
|
||||
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
@@ -58,6 +58,7 @@
|
||||
<Compile Include="Commands\UserCommands.cs" />
|
||||
<Compile Include="Controllers\AccountController.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Drivers\UserPartDriver.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Events\UserContext.cs" />
|
||||
<Compile Include="Handlers\UserMessagesAlteration.cs" />
|
||||
|
Reference in New Issue
Block a user