diff --git a/ApplicantTracking.Data/ApplicantTracking.Data.csproj b/ApplicantTracking.Data/ApplicantTracking.Data.csproj index f4049c1..cd45849 100644 --- a/ApplicantTracking.Data/ApplicantTracking.Data.csproj +++ b/ApplicantTracking.Data/ApplicantTracking.Data.csproj @@ -85,6 +85,10 @@ + + + + 201803082336377_InitialCreate.cs @@ -98,7 +102,6 @@ - diff --git a/ApplicantTracking.Data/Identity/ApplicationSignInManager.cs b/ApplicantTracking.Data/Identity/ApplicationSignInManager.cs new file mode 100644 index 0000000..b75bbc3 --- /dev/null +++ b/ApplicantTracking.Data/Identity/ApplicationSignInManager.cs @@ -0,0 +1,27 @@ +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNet.Identity.Owin; +using Microsoft.Owin; +using Microsoft.Owin.Security; + +namespace ApplicantTracking.Data.Identity +{ + // 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/ApplicantTracking.Data/Identity/IdentityConfig.cs b/ApplicantTracking.Data/Identity/ApplicationUserManager.cs similarity index 62% rename from ApplicantTracking.Data/Identity/IdentityConfig.cs rename to ApplicantTracking.Data/Identity/ApplicationUserManager.cs index caf01fc..08942f5 100644 --- a/ApplicantTracking.Data/Identity/IdentityConfig.cs +++ b/ApplicantTracking.Data/Identity/ApplicationUserManager.cs @@ -1,34 +1,13 @@ using System; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin; -using Microsoft.Owin.Security; namespace ApplicantTracking.Data.Identity { - 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. + // 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) @@ -36,7 +15,7 @@ public ApplicationUserManager(IUserStore store) { } - public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) + public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) { var manager = new ApplicationUserManager(new UserStore(context.Get())); // Configure validation logic for usernames @@ -67,39 +46,25 @@ public static ApplicationUserManager Create(IdentityFactoryOptions { 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 = + 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); + return manager; } } } diff --git a/ApplicantTracking.Data/Identity/EmailService.cs b/ApplicantTracking.Data/Identity/EmailService.cs new file mode 100644 index 0000000..c46e73e --- /dev/null +++ b/ApplicantTracking.Data/Identity/EmailService.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; + +namespace ApplicantTracking.Data.Identity +{ + 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/ApplicantTracking.Data/Identity/SmsService.cs b/ApplicantTracking.Data/Identity/SmsService.cs new file mode 100644 index 0000000..20d18b6 --- /dev/null +++ b/ApplicantTracking.Data/Identity/SmsService.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; +using Microsoft.AspNet.Identity; + +namespace ApplicantTracking.Data.Identity +{ + 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/ApplicantTracking.Web/Startup.cs b/ApplicantTracking.Web/Startup.cs index 465a677..1a5a2bc 100644 --- a/ApplicantTracking.Web/Startup.cs +++ b/ApplicantTracking.Web/Startup.cs @@ -1,7 +1,7 @@ using Microsoft.Owin; using Owin; -[assembly: OwinStartupAttribute(typeof(ApplicantTracking.Web.Startup))] +[assembly: OwinStartup(typeof(ApplicantTracking.Web.Startup))] namespace ApplicantTracking.Web { public partial class Startup