diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/Answer.cs b/Trunk/Components/Forum.DataAccessLayer.Models/Answer.cs new file mode 100644 index 0000000..5d28640 --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/Answer.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Forum.DataAccessLayer.Models +{ + class Answer + { + } +} diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/App.config b/Trunk/Components/Forum.DataAccessLayer.Models/App.config new file mode 100644 index 0000000..7e1d79c --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/App.config @@ -0,0 +1,17 @@ + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/Category.cs b/Trunk/Components/Forum.DataAccessLayer.Models/Category.cs new file mode 100644 index 0000000..019db53 --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/Category.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Forum.DataAccessLayer.Models +{ + class Category + { + } +} diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/Forum.DataAccessLayer.Models.csproj b/Trunk/Components/Forum.DataAccessLayer.Models/Forum.DataAccessLayer.Models.csproj new file mode 100644 index 0000000..1b954e1 --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/Forum.DataAccessLayer.Models.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {9F24444B-F36F-4965-BC49-C5BF885278EE} + Library + Properties + Forum.DataAccessLayer.Models + Forum.DataAccessLayer.Models + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\Server\Forum\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\Server\Forum\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\..\Server\Forum\packages\Microsoft.AspNet.Identity.Core.2.2.2\lib\net45\Microsoft.AspNet.Identity.Core.dll + + + ..\..\Server\Forum\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.2\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/ProfessionalUser.cs b/Trunk/Components/Forum.DataAccessLayer.Models/ProfessionalUser.cs new file mode 100644 index 0000000..050e1e4 --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/ProfessionalUser.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; +using Microsoft.AspNet.Identity.EntityFramework; + +namespace Forum.DataAccessLayer.Models +{ + public class ProfessionalUser : IdentityUser + { + public async Task GenerateUserIdentityAsync(UserManager manager) + { + // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType + var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); + // Add custom user claims here + return userIdentity; + } + } +} diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/Properties/AssemblyInfo.cs b/Trunk/Components/Forum.DataAccessLayer.Models/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2eec4a5 --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Forum.DataAccessLayer.Models")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Forum.DataAccessLayer.Models")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9f24444b-f36f-4965-bc49-c5bf885278ee")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/Question.cs b/Trunk/Components/Forum.DataAccessLayer.Models/Question.cs new file mode 100644 index 0000000..5b9653f --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/Question.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Forum.DataAccessLayer.Models +{ + class Question + { + } +} diff --git a/Trunk/Components/Forum.DataAccessLayer.Models/packages.config b/Trunk/Components/Forum.DataAccessLayer.Models/packages.config new file mode 100644 index 0000000..6106fda --- /dev/null +++ b/Trunk/Components/Forum.DataAccessLayer.Models/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/App.config b/Trunk/Server/Forum/Forum.DataAccessLayer/App.config new file mode 100644 index 0000000..47314cf --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/App.config @@ -0,0 +1,41 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs new file mode 100644 index 0000000..aff3723 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/ContextProviders/ApplicationDbContext.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Forum.DataAccessLayer.Models; +using Microsoft.AspNet.Identity.EntityFramework; + +namespace Forum.DataAccessLayer +{ + public class ApplicationDbContext : IdentityDbContext + { + public ApplicationDbContext() + : base("DefaultConnection", throwIfV1Schema: false) + { + } + + public static ApplicationDbContext Create() + { + return new ApplicationDbContext(); + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj b/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj new file mode 100644 index 0000000..deb4235 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Forum.DataAccessLayer.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {AF3E6195-741F-46E7-BAA6-F67CD91D285A} + Library + Properties + Forum.DataAccessLayer + Forum.DataAccessLayer + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Microsoft.AspNet.Identity.Core.2.2.2\lib\net45\Microsoft.AspNet.Identity.Core.dll + + + ..\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.2\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll + + + ..\packages\Microsoft.AspNet.Identity.Owin.2.2.2\lib\net45\Microsoft.AspNet.Identity.Owin.dll + + + ..\packages\Microsoft.Owin.4.0.0\lib\net451\Microsoft.Owin.dll + + + ..\packages\Microsoft.Owin.Security.4.0.0\lib\net451\Microsoft.Owin.Security.dll + + + ..\packages\Microsoft.Owin.Security.Cookies.4.0.0\lib\net451\Microsoft.Owin.Security.Cookies.dll + + + ..\packages\Microsoft.Owin.Security.OAuth.4.0.0\lib\net451\Microsoft.Owin.Security.OAuth.dll + + + ..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + + + + + + + + + + + + + + + + + + 201812012107132_Db init.cs + + + + + + + + + + + + + + + + {9f24444b-f36f-4965-bc49-c5bf885278ee} + Forum.DataAccessLayer.Models + + + + + 201812012107132_Db init.cs + + + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationSignInManager.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationSignInManager.cs new file mode 100644 index 0000000..b5e6368 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationSignInManager.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Claims; +using System.Text; +using System.Threading.Tasks; +using Forum.DataAccessLayer.Models; +using Microsoft.AspNet.Identity.Owin; +using Microsoft.Owin; +using Microsoft.Owin.Security; + +namespace Forum.DataAccessLayer.Managers +{ + public class ApplicationSignInManager : SignInManager + { + public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager) + : base(userManager, authenticationManager) + { + } + + public override Task CreateUserIdentityAsync(ProfessionalUser user) + { + return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager); + } + + public static ApplicationSignInManager Create(IdentityFactoryOptions options, IOwinContext context) + { + return new ApplicationSignInManager(context.GetUserManager(), context.Authentication); + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationUserManager.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationUserManager.cs new file mode 100644 index 0000000..8b31ffc --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Managers/ApplicationUserManager.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Forum.DataAccessLayer.Models; +using Forum.DataAccessLayer.Services; +using Microsoft.AspNet.Identity; +using Microsoft.AspNet.Identity.EntityFramework; +using Microsoft.AspNet.Identity.Owin; +using Microsoft.Owin; + +namespace Forum.DataAccessLayer.Managers +{ + public class ApplicationUserManager : UserManager + { + public ApplicationUserManager(IUserStore store) + : base(store) + { + } + + public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) + { + var manager = new ApplicationUserManager(new UserStore(context.Get())); + // Configure validation logic for usernames + manager.UserValidator = new UserValidator(manager) + { + AllowOnlyAlphanumericUserNames = false, + RequireUniqueEmail = true + }; + + // Configure validation logic for passwords + manager.PasswordValidator = new PasswordValidator + { + RequiredLength = 6, + RequireNonLetterOrDigit = true, + RequireDigit = true, + RequireLowercase = true, + RequireUppercase = true, + }; + + // Configure user lockout defaults + manager.UserLockoutEnabledByDefault = true; + manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); + manager.MaxFailedAccessAttemptsBeforeLockout = 5; + + // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user + // You can write your own provider and plug it in here. + manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider + { + MessageFormat = "Your security code is {0}" + }); + manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider + { + Subject = "Security Code", + BodyFormat = "Your security code is {0}" + }); + manager.EmailService = new EmailService(); + manager.SmsService = new SmsService(); + var dataProtectionProvider = options.DataProtectionProvider; + if (dataProtectionProvider != null) + { + manager.UserTokenProvider = + new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); + } + return manager; + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.Designer.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.Designer.cs new file mode 100644 index 0000000..27e241d --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.Designer.cs @@ -0,0 +1,29 @@ +// +namespace Forum.DataAccessLayer.Migrations +{ + using System.CodeDom.Compiler; + using System.Data.Entity.Migrations; + using System.Data.Entity.Migrations.Infrastructure; + using System.Resources; + + [GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")] + public sealed partial class Dbinit : IMigrationMetadata + { + private readonly ResourceManager Resources = new ResourceManager(typeof(Dbinit)); + + string IMigrationMetadata.Id + { + get { return "201812012107132_Db init"; } + } + + string IMigrationMetadata.Source + { + get { return null; } + } + + string IMigrationMetadata.Target + { + get { return Resources.GetString("Target"); } + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.cs new file mode 100644 index 0000000..6f7a214 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.cs @@ -0,0 +1,99 @@ +namespace Forum.DataAccessLayer.Migrations +{ + using System; + using System.Data.Entity.Migrations; + + public partial class Dbinit : DbMigration + { + public override void Up() + { + CreateTable( + "dbo.AspNetRoles", + c => new + { + Id = c.String(nullable: false, maxLength: 128), + Name = c.String(nullable: false, maxLength: 256), + }) + .PrimaryKey(t => t.Id) + .Index(t => t.Name, unique: true, name: "RoleNameIndex"); + + CreateTable( + "dbo.AspNetUserRoles", + c => new + { + UserId = c.String(nullable: false, maxLength: 128), + RoleId = c.String(nullable: false, maxLength: 128), + }) + .PrimaryKey(t => new { t.UserId, t.RoleId }) + .ForeignKey("dbo.AspNetRoles", t => t.RoleId, cascadeDelete: true) + .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true) + .Index(t => t.UserId) + .Index(t => t.RoleId); + + CreateTable( + "dbo.AspNetUsers", + c => new + { + Id = c.String(nullable: false, maxLength: 128), + Email = c.String(maxLength: 256), + EmailConfirmed = c.Boolean(nullable: false), + PasswordHash = c.String(), + SecurityStamp = c.String(), + PhoneNumber = c.String(), + PhoneNumberConfirmed = c.Boolean(nullable: false), + TwoFactorEnabled = c.Boolean(nullable: false), + LockoutEndDateUtc = c.DateTime(), + LockoutEnabled = c.Boolean(nullable: false), + AccessFailedCount = c.Int(nullable: false), + UserName = c.String(nullable: false, maxLength: 256), + }) + .PrimaryKey(t => t.Id) + .Index(t => t.UserName, unique: true, name: "UserNameIndex"); + + CreateTable( + "dbo.AspNetUserClaims", + c => new + { + Id = c.Int(nullable: false, identity: true), + UserId = c.String(nullable: false, maxLength: 128), + ClaimType = c.String(), + ClaimValue = c.String(), + }) + .PrimaryKey(t => t.Id) + .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true) + .Index(t => t.UserId); + + CreateTable( + "dbo.AspNetUserLogins", + c => new + { + LoginProvider = c.String(nullable: false, maxLength: 128), + ProviderKey = c.String(nullable: false, maxLength: 128), + UserId = c.String(nullable: false, maxLength: 128), + }) + .PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId }) + .ForeignKey("dbo.AspNetUsers", t => t.UserId, cascadeDelete: true) + .Index(t => t.UserId); + + } + + public override void Down() + { + DropForeignKey("dbo.AspNetUserRoles", "UserId", "dbo.AspNetUsers"); + DropForeignKey("dbo.AspNetUserLogins", "UserId", "dbo.AspNetUsers"); + DropForeignKey("dbo.AspNetUserClaims", "UserId", "dbo.AspNetUsers"); + DropForeignKey("dbo.AspNetUserRoles", "RoleId", "dbo.AspNetRoles"); + DropIndex("dbo.AspNetUserLogins", new[] { "UserId" }); + DropIndex("dbo.AspNetUserClaims", new[] { "UserId" }); + DropIndex("dbo.AspNetUsers", "UserNameIndex"); + DropIndex("dbo.AspNetUserRoles", new[] { "RoleId" }); + DropIndex("dbo.AspNetUserRoles", new[] { "UserId" }); + DropIndex("dbo.AspNetRoles", "RoleNameIndex"); + DropTable("dbo.AspNetUserLogins"); + DropTable("dbo.AspNetUserClaims"); + DropTable("dbo.AspNetUsers"); + DropTable("dbo.AspNetUserRoles"); + DropTable("dbo.AspNetRoles"); + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.resx b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.resx new file mode 100644 index 0000000..708c51d --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/201812012107132_Db init.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + H4sIAAAAAAAEAN1cW2/ruBF+L9D/IOipLbJWLj0Hp4G9i6wTt0Fzw3HOom8HtEQ7wpEorURlExT7y/qwP2n/Qoe6ixeJshVbWSywOBaH3wyHQ85wOMzv//tt+sOL7xnPOIrdgMzMk8mxaWBiB45LNjMzoevvPpk/fP/nP02vHP/F+KmgO2N00JPEM/OJ0vDcsmL7CfsonviuHQVxsKYTO/At5ATW6fHxP6yTEwsDhAlYhjH9nBDq+jj9AT/nAbFxSBPk3QYO9uL8O7QsU1TjDvk4DpGNZ+YiiBJ/cokourBtHMc36BVHpnHhuQiEWWJvbRqIkIAiCqKef4nxkkYB2SxD+IC8x9cQA90aeTHOh3BekeuO5viUjcaqOhZQdhLTwO8JeHKWq8fiu2+lZLNUHyjwChRNX9moUyXOzGsHp58+Bx4ogGd4PvciRjwzb0sWF3F4h+mk6DjJIBcRwP0SRN8mdcQjQ7vfUWlOp5Nj9t+RMU88mkR4RnBCI+QdGQ/JynPtf+PXx+AbJrOzk9X67NOHj8g5+/h3fPahPlIYK9A1PsCnhygIcQSy4XU5ftOwmv0svmPZrdYn0wrYEqwM07hFLzeYbOgTrJnTT6axcF+wU3zJjesLcWEhQScaJfD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pHrvB9SsUHpu9HcqVHtratN3pwYt+xZIlxc2OLKXcVdSb5d9nprMKwAqy6DJ7nSkvHGsrgO1gWJGomaor1njG4tIRGIsk7Yz7jTb3/a3DzWna2SoqPtt4526glXdO085bUUN5iHpkaQWjrEi8YytrK6x6Z/XHjcF0lbx3hbCtl/XvrNx4GMU0VpHi0vldVRcPo5Yhl1GPamLxDhk8ae3vQII3j91NBcH+KiTBdsOHljTXZB0UrpyTqCDhcje3mCKH1TFE1F0jm0IzS02nj83TdB+7IFlh55rcJzRMKAwZ+yuvkQpjIUEb/7Rkuinz9D5M/3TKEEMAMV2W0r8nPyau55RyLyTZIgUEizXyRDCbS8oSwpvXEukuIJpAufrKEOkR+6EHYPE9WaJnvI1sYH43eIPs1yo3qALpnoim2qeXLtpEyI9zjKo//AQbdvyX7/8P0D0f8A5VAAA= + + + dbo + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs new file mode 100644 index 0000000..68fb04a --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs @@ -0,0 +1,23 @@ +namespace Forum.DataAccessLayer.Migrations +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Migrations; + using System.Linq; + + internal sealed class Configuration : DbMigrationsConfiguration + { + public Configuration() + { + AutomaticMigrationsEnabled = false; + } + + protected override void Seed(Forum.DataAccessLayer.ApplicationDbContext context) + { + // This method will be called after migrating to the latest version. + + // You can use the DbSet.AddOrUpdate() helper extension method + // to avoid creating duplicate seed data. + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Properties/AssemblyInfo.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6f353be --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Forum.DataAccessLayer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Forum.DataAccessLayer")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("af3e6195-741f-46e7-baa6-f67cd91d285a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Services/MailService.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Services/MailService.cs new file mode 100644 index 0000000..8492f55 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Services/MailService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; + +namespace Forum.DataAccessLayer.Services +{ + public class EmailService : IIdentityMessageService + { + public Task SendAsync(IdentityMessage message) + { + // Plug in your email service here to send an email. + return Task.FromResult(0); + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/Services/SmsService.cs b/Trunk/Server/Forum/Forum.DataAccessLayer/Services/SmsService.cs new file mode 100644 index 0000000..8108592 --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/Services/SmsService.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; + +namespace Forum.DataAccessLayer.Services +{ + public class SmsService : IIdentityMessageService + { + public Task SendAsync(IdentityMessage message) + { + // Plug in your SMS service here to send a text message. + return Task.FromResult(0); + } + } +} diff --git a/Trunk/Server/Forum/Forum.DataAccessLayer/packages.config b/Trunk/Server/Forum/Forum.DataAccessLayer/packages.config new file mode 100644 index 0000000..805446e --- /dev/null +++ b/Trunk/Server/Forum/Forum.DataAccessLayer/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum.sln b/Trunk/Server/Forum/Forum.sln index b53b9f4..dfaa175 100644 --- a/Trunk/Server/Forum/Forum.sln +++ b/Trunk/Server/Forum/Forum.sln @@ -5,6 +5,12 @@ VisualStudioVersion = 15.0.28307.136 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forum", "Forum\Forum.csproj", "{E3C0D1F3-C4CC-4D3D-9960-F20179C60269}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forum.DataAccessLayer.Models", "..\..\Components\Forum.DataAccessLayer.Models\Forum.DataAccessLayer.Models.csproj", "{9F24444B-F36F-4965-BC49-C5BF885278EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data Access Layer", "Data Access Layer", "{380457AD-9C28-43E7-B606-2C55E1D5D26B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forum.DataAccessLayer", "Forum.DataAccessLayer\Forum.DataAccessLayer.csproj", "{AF3E6195-741F-46E7-BAA6-F67CD91D285A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,10 +21,22 @@ Global {E3C0D1F3-C4CC-4D3D-9960-F20179C60269}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3C0D1F3-C4CC-4D3D-9960-F20179C60269}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3C0D1F3-C4CC-4D3D-9960-F20179C60269}.Release|Any CPU.Build.0 = Release|Any CPU + {9F24444B-F36F-4965-BC49-C5BF885278EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9F24444B-F36F-4965-BC49-C5BF885278EE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F24444B-F36F-4965-BC49-C5BF885278EE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9F24444B-F36F-4965-BC49-C5BF885278EE}.Release|Any CPU.Build.0 = Release|Any CPU + {AF3E6195-741F-46E7-BAA6-F67CD91D285A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF3E6195-741F-46E7-BAA6-F67CD91D285A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF3E6195-741F-46E7-BAA6-F67CD91D285A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF3E6195-741F-46E7-BAA6-F67CD91D285A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {9F24444B-F36F-4965-BC49-C5BF885278EE} = {380457AD-9C28-43E7-B606-2C55E1D5D26B} + {AF3E6195-741F-46E7-BAA6-F67CD91D285A} = {380457AD-9C28-43E7-B606-2C55E1D5D26B} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {341ABE52-6FD4-4A2C-8A64-7CAA19241B68} EndGlobalSection diff --git a/Trunk/Server/Forum/Forum/App_Start/IdentityConfig.cs b/Trunk/Server/Forum/Forum/App_Start/IdentityConfig.cs index 953fe4b..e0e5a7e 100644 --- a/Trunk/Server/Forum/Forum/App_Start/IdentityConfig.cs +++ b/Trunk/Server/Forum/Forum/App_Start/IdentityConfig.cs @@ -14,96 +14,13 @@ using Forum.Models; namespace Forum { - public class EmailService : IIdentityMessageService - { - public Task SendAsync(IdentityMessage message) - { - // Plug in your email service here to send an email. - return Task.FromResult(0); - } - } + - public class SmsService : IIdentityMessageService - { - public Task SendAsync(IdentityMessage message) - { - // Plug in your SMS service here to send a text message. - return Task.FromResult(0); - } - } + // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application. - public class ApplicationUserManager : UserManager - { - public ApplicationUserManager(IUserStore store) - : base(store) - { - } - - public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) - { - var manager = new ApplicationUserManager(new UserStore(context.Get())); - // Configure validation logic for usernames - manager.UserValidator = new UserValidator(manager) - { - AllowOnlyAlphanumericUserNames = false, - RequireUniqueEmail = true - }; - - // Configure validation logic for passwords - manager.PasswordValidator = new PasswordValidator - { - RequiredLength = 6, - RequireNonLetterOrDigit = true, - RequireDigit = true, - RequireLowercase = true, - RequireUppercase = true, - }; - - // Configure user lockout defaults - manager.UserLockoutEnabledByDefault = true; - manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); - manager.MaxFailedAccessAttemptsBeforeLockout = 5; - - // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user - // You can write your own provider and plug it in here. - manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider - { - MessageFormat = "Your security code is {0}" - }); - manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider - { - Subject = "Security Code", - BodyFormat = "Your security code is {0}" - }); - manager.EmailService = new EmailService(); - manager.SmsService = new SmsService(); - var dataProtectionProvider = options.DataProtectionProvider; - if (dataProtectionProvider != null) - { - manager.UserTokenProvider = - new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); - } - return manager; - } - } + // Configure the application sign-in manager which is used in this application. - public class ApplicationSignInManager : SignInManager - { - public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager) - : base(userManager, authenticationManager) - { - } - - public override Task CreateUserIdentityAsync(ApplicationUser user) - { - return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager); - } - - public static ApplicationSignInManager Create(IdentityFactoryOptions options, IOwinContext context) - { - return new ApplicationSignInManager(context.GetUserManager(), context.Authentication); - } - } + } diff --git a/Trunk/Server/Forum/Forum/App_Start/Startup.Auth.cs b/Trunk/Server/Forum/Forum/App_Start/Startup.Auth.cs index 39723b7..151f34d 100644 --- a/Trunk/Server/Forum/Forum/App_Start/Startup.Auth.cs +++ b/Trunk/Server/Forum/Forum/App_Start/Startup.Auth.cs @@ -1,4 +1,7 @@ using System; +using Forum.DataAccessLayer; +using Forum.DataAccessLayer.Managers; +using Forum.DataAccessLayer.Models; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin; @@ -30,7 +33,7 @@ namespace Forum { // Enables the application to validate the security stamp when the user logs in. // This is a security feature which is used when you change a password or add an external login to your account. - OnValidateIdentity = SecurityStampValidator.OnValidateIdentity( + OnValidateIdentity = SecurityStampValidator.OnValidateIdentity( validateInterval: TimeSpan.FromMinutes(30), regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) } diff --git a/Trunk/Server/Forum/Forum/Controllers/AccountController.cs b/Trunk/Server/Forum/Forum/Controllers/AccountController.cs index e534e04..7f8086d 100644 --- a/Trunk/Server/Forum/Forum/Controllers/AccountController.cs +++ b/Trunk/Server/Forum/Forum/Controllers/AccountController.cs @@ -5,6 +5,8 @@ using System.Security.Claims; using System.Threading.Tasks; using System.Web; using System.Web.Mvc; +using Forum.DataAccessLayer.Managers; +using Forum.DataAccessLayer.Models; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin.Security; @@ -151,7 +153,7 @@ namespace Forum.Controllers { if (ModelState.IsValid) { - var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; + var user = new ProfessionalUser() { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { @@ -367,7 +369,7 @@ namespace Forum.Controllers { return View("ExternalLoginFailure"); } - var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; + var user = new ProfessionalUser() { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { diff --git a/Trunk/Server/Forum/Forum/Controllers/ManageController.cs b/Trunk/Server/Forum/Forum/Controllers/ManageController.cs index 240889d..8fa21a0 100644 --- a/Trunk/Server/Forum/Forum/Controllers/ManageController.cs +++ b/Trunk/Server/Forum/Forum/Controllers/ManageController.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.Mvc; +using Forum.DataAccessLayer.Managers; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin.Security; diff --git a/Trunk/Server/Forum/Forum/Forum.csproj b/Trunk/Server/Forum/Forum/Forum.csproj index 0db28c2..0fd26fb 100644 --- a/Trunk/Server/Forum/Forum/Forum.csproj +++ b/Trunk/Server/Forum/Forum/Forum.csproj @@ -180,7 +180,6 @@ Global.asax - @@ -258,6 +257,16 @@ + + + {9F24444B-F36F-4965-BC49-C5BF885278EE} + Forum.DataAccessLayer.Models + + + {af3e6195-741f-46e7-baa6-f67cd91d285a} + Forum.DataAccessLayer + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/Trunk/Server/Forum/Forum/Models/IdentityModels.cs b/Trunk/Server/Forum/Forum/Models/IdentityModels.cs deleted file mode 100644 index df6a261..0000000 --- a/Trunk/Server/Forum/Forum/Models/IdentityModels.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Data.Entity; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNet.Identity; -using Microsoft.AspNet.Identity.EntityFramework; - -namespace Forum.Models -{ - // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit https://go.microsoft.com/fwlink/?LinkID=317594 to learn more. - public class ApplicationUser : IdentityUser - { - public async Task GenerateUserIdentityAsync(UserManager manager) - { - // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType - var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); - // Add custom user claims here - return userIdentity; - } - } - - public class ApplicationDbContext : IdentityDbContext - { - public ApplicationDbContext() - : base("DefaultConnection", throwIfV1Schema: false) - { - } - - public static ApplicationDbContext Create() - { - return new ApplicationDbContext(); - } - } -} \ No newline at end of file diff --git a/Trunk/Server/Forum/Forum/Web.config b/Trunk/Server/Forum/Forum/Web.config index 8304abe..6e51583 100644 --- a/Trunk/Server/Forum/Forum/Web.config +++ b/Trunk/Server/Forum/Forum/Web.config @@ -1,4 +1,4 @@ - + -
+
- + - - - - + + + + - - - + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - - + + \ No newline at end of file