├── .gitattributes ├── .gitignore ├── A11_RBS ├── A11_RBS.csproj ├── A11_RBS.csproj.user ├── App_Data │ ├── SuperMarket.mdf │ ├── SuperMarket_log.ldf │ ├── aspnet-A11_RBS-20150128074222.mdf │ └── aspnet-A11_RBS-20150128074222_log.ldf ├── App_Start │ ├── BundleConfig.cs │ ├── FilterConfig.cs │ ├── IdentityConfig.cs │ ├── RouteConfig.cs │ └── Startup.Auth.cs ├── Content │ ├── Site.css │ ├── bootstrap.css │ └── bootstrap.min.css ├── Controllers │ ├── AccountController.cs │ ├── HomeController.cs │ ├── ManageController.cs │ ├── ProductController.cs │ └── RoleController.cs ├── CustomFilters │ └── LogAuthFilter.cs ├── Global.asax ├── Global.asax.cs ├── Models │ ├── AccountViewModels.cs │ ├── IdentityModels.cs │ ├── ManageViewModels.cs │ ├── ProductMaster.cs │ ├── SuperMarketEDMX.Context.cs │ ├── SuperMarketEDMX.Context.tt │ ├── SuperMarketEDMX.Designer.cs │ ├── SuperMarketEDMX.cs │ ├── SuperMarketEDMX.edmx │ ├── SuperMarketEDMX.edmx.diagram │ ├── SuperMarketEDMX.tt │ └── UnAuthorizeModel.cs ├── Project_Readme.html ├── Properties │ └── AssemblyInfo.cs ├── Scripts │ ├── _references.js │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── jquery-1.10.2.intellisense.js │ ├── jquery-1.10.2.js │ ├── jquery-1.10.2.min.js │ ├── jquery-1.10.2.min.map │ ├── jquery.validate-vsdoc.js │ ├── jquery.validate.js │ ├── jquery.validate.min.js │ ├── jquery.validate.unobtrusive.js │ ├── jquery.validate.unobtrusive.min.js │ ├── modernizr-2.6.2.js │ ├── respond.js │ └── respond.min.js ├── Startup.cs ├── Views │ ├── Account │ │ ├── ConfirmEmail.cshtml │ │ ├── ExternalLoginConfirmation.cshtml │ │ ├── ExternalLoginFailure.cshtml │ │ ├── ForgotPassword.cshtml │ │ ├── ForgotPasswordConfirmation.cshtml │ │ ├── Login.cshtml │ │ ├── Register.cshtml │ │ ├── ResetPassword.cshtml │ │ ├── ResetPasswordConfirmation.cshtml │ │ ├── SendCode.cshtml │ │ ├── VerifyCode.cshtml │ │ └── _ExternalLoginsListPartial.cshtml │ ├── Home │ │ ├── About.cshtml │ │ ├── Contact.cshtml │ │ └── Index.cshtml │ ├── Manage │ │ ├── AddPhoneNumber.cshtml │ │ ├── ChangePassword.cshtml │ │ ├── Index.cshtml │ │ ├── ManageLogins.cshtml │ │ ├── SetPassword.cshtml │ │ └── VerifyPhoneNumber.cshtml │ ├── Product │ │ ├── Create.cshtml │ │ ├── Index.cshtml │ │ └── SaleProduct.cshtml │ ├── Role │ │ ├── Create.cshtml │ │ ├── Index.cshtml │ │ └── SetRoleToUser.cshtml │ ├── Shared │ │ ├── AuthorizeFailed.cshtml │ │ ├── Error.cshtml │ │ ├── Lockout.cshtml │ │ ├── _Layout.cshtml │ │ └── _LoginPartial.cshtml │ ├── Web.config │ └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── obj │ └── Debug │ │ ├── A11_RBS.csproj.FileListAbsolute.txt │ │ ├── A11_RBS.csprojResolveAssemblyReference.cache │ │ ├── A11_RBS.dll │ │ ├── A11_RBS.pdb │ │ ├── DesignTimeResolveAssemblyReferencesInput.cache │ │ ├── TempPE │ │ ├── Models.SuperMarketEDMX.Designer.cs.dll │ │ └── Models.SuperMarketEDMX.cs.dll │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs │ │ └── edmxResourcesToEmbed │ │ └── Models │ │ ├── SuperMarketEDMX.csdl │ │ ├── SuperMarketEDMX.msl │ │ └── SuperMarketEDMX.ssdl └── packages.config └── prd.sql /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /A11_RBS/A11_RBS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 8 | 9 | 2.0 10 | {2A7BA3BA-12D8-42A7-9B7B-7148D773DF80} 11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 12 | Library 13 | Properties 14 | A11_RBS 15 | A11_RBS 16 | v4.5.1 17 | false 18 | true 19 | 20 | 21 | 22 | 23 | 24 | 25 | true 26 | full 27 | false 28 | bin\ 29 | DEBUG;TRACE 30 | prompt 31 | 4 32 | 33 | 34 | pdbonly 35 | true 36 | bin\ 37 | TRACE 38 | prompt 39 | 4 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | True 65 | ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll 66 | 67 | 68 | 69 | 70 | 71 | 72 | True 73 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll 74 | 75 | 76 | True 77 | ..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll 78 | 79 | 80 | ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll 81 | 82 | 83 | True 84 | ..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll 85 | 86 | 87 | True 88 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll 89 | 90 | 91 | True 92 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll 93 | 94 | 95 | True 96 | ..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll 97 | 98 | 99 | True 100 | ..\packages\WebGrease.1.5.2\lib\WebGrease.dll 101 | 102 | 103 | True 104 | ..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll 105 | 106 | 107 | 108 | 109 | ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll 110 | 111 | 112 | ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll 113 | 114 | 115 | ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll 116 | 117 | 118 | ..\packages\Microsoft.AspNet.Identity.Core.2.1.0\lib\net45\Microsoft.AspNet.Identity.Core.dll 119 | 120 | 121 | ..\packages\Microsoft.AspNet.Identity.Owin.2.1.0\lib\net45\Microsoft.AspNet.Identity.Owin.dll 122 | 123 | 124 | ..\packages\Microsoft.AspNet.Identity.EntityFramework.2.1.0\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll 125 | 126 | 127 | ..\packages\Owin.1.0\lib\net40\Owin.dll 128 | 129 | 130 | ..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll 131 | 132 | 133 | ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll 134 | 135 | 136 | ..\packages\Microsoft.Owin.Security.3.0.0\lib\net45\Microsoft.Owin.Security.dll 137 | 138 | 139 | ..\packages\Microsoft.Owin.Security.Facebook.3.0.0\lib\net45\Microsoft.Owin.Security.Facebook.dll 140 | 141 | 142 | ..\packages\Microsoft.Owin.Security.Cookies.3.0.0\lib\net45\Microsoft.Owin.Security.Cookies.dll 143 | 144 | 145 | ..\packages\Microsoft.Owin.Security.OAuth.3.0.0\lib\net45\Microsoft.Owin.Security.OAuth.dll 146 | 147 | 148 | ..\packages\Microsoft.Owin.Security.Google.3.0.0\lib\net45\Microsoft.Owin.Security.Google.dll 149 | 150 | 151 | ..\packages\Microsoft.Owin.Security.Twitter.3.0.0\lib\net45\Microsoft.Owin.Security.Twitter.dll 152 | 153 | 154 | ..\packages\Microsoft.Owin.Security.MicrosoftAccount.3.0.0\lib\net45\Microsoft.Owin.Security.MicrosoftAccount.dll 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | Global.asax 171 | 172 | 173 | 174 | 175 | 176 | SuperMarketEDMX.tt 177 | 178 | 179 | True 180 | True 181 | SuperMarketEDMX.Context.tt 182 | 183 | 184 | True 185 | True 186 | SuperMarketEDMX.tt 187 | 188 | 189 | True 190 | True 191 | SuperMarketEDMX.edmx 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | SuperMarket.mdf 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | TextTemplatingFileGenerator 210 | SuperMarketEDMX.edmx 211 | SuperMarketEDMX.Context.cs 212 | 213 | 214 | TextTemplatingFileGenerator 215 | SuperMarketEDMX.edmx 216 | SuperMarketEDMX.cs 217 | 218 | 219 | 220 | 221 | EntityModelCodeGenerator 222 | SuperMarketEDMX.Designer.cs 223 | 224 | 225 | SuperMarketEDMX.edmx 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | Web.config 242 | 243 | 244 | Web.config 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 10.0 295 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | True 308 | True 309 | 62439 310 | / 311 | http://localhost:62439/ 312 | False 313 | False 314 | 315 | 316 | False 317 | 318 | 319 | 320 | 321 | 327 | -------------------------------------------------------------------------------- /A11_RBS/A11_RBS.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 600 5 | True 6 | False 7 | False 8 | 9 | False 10 | 600 11 | A11_RBS.Models.SuperMarketEntities 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | CurrentPage 20 | True 21 | False 22 | False 23 | False 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | True 33 | True 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /A11_RBS/App_Data/SuperMarket.mdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/App_Data/SuperMarket.mdf -------------------------------------------------------------------------------- /A11_RBS/App_Data/SuperMarket_log.ldf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/App_Data/SuperMarket_log.ldf -------------------------------------------------------------------------------- /A11_RBS/App_Data/aspnet-A11_RBS-20150128074222.mdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/App_Data/aspnet-A11_RBS-20150128074222.mdf -------------------------------------------------------------------------------- /A11_RBS/App_Data/aspnet-A11_RBS-20150128074222_log.ldf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/App_Data/aspnet-A11_RBS-20150128074222_log.ldf -------------------------------------------------------------------------------- /A11_RBS/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Optimization; 3 | 4 | namespace A11_RBS 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new ScriptBundle("~/bundles/jquery").Include( 12 | "~/Scripts/jquery-{version}.js")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( 15 | "~/Scripts/jquery.validate*")); 16 | 17 | // Use the development version of Modernizr to develop with and learn from. Then, when you're 18 | // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 19 | bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( 20 | "~/Scripts/modernizr-*")); 21 | 22 | bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include( 23 | "~/Scripts/bootstrap.js", 24 | "~/Scripts/respond.js")); 25 | 26 | bundles.Add(new StyleBundle("~/Content/css").Include( 27 | "~/Content/bootstrap.css", 28 | "~/Content/site.css")); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /A11_RBS/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace A11_RBS 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /A11_RBS/App_Start/IdentityConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data.Entity; 4 | using System.Linq; 5 | using System.Security.Claims; 6 | using System.Threading.Tasks; 7 | using System.Web; 8 | using Microsoft.AspNet.Identity; 9 | using Microsoft.AspNet.Identity.EntityFramework; 10 | using Microsoft.AspNet.Identity.Owin; 11 | using Microsoft.Owin; 12 | using Microsoft.Owin.Security; 13 | using A11_RBS.Models; 14 | 15 | namespace A11_RBS 16 | { 17 | public class EmailService : IIdentityMessageService 18 | { 19 | public Task SendAsync(IdentityMessage message) 20 | { 21 | // Plug in your email service here to send an email. 22 | return Task.FromResult(0); 23 | } 24 | } 25 | 26 | public class SmsService : IIdentityMessageService 27 | { 28 | public Task SendAsync(IdentityMessage message) 29 | { 30 | // Plug in your SMS service here to send a text message. 31 | return Task.FromResult(0); 32 | } 33 | } 34 | 35 | // Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application. 36 | public class ApplicationUserManager : UserManager 37 | { 38 | public ApplicationUserManager(IUserStore store) 39 | : base(store) 40 | { 41 | } 42 | 43 | public static ApplicationUserManager Create(IdentityFactoryOptions options, IOwinContext context) 44 | { 45 | var manager = new ApplicationUserManager(new UserStore(context.Get())); 46 | // Configure validation logic for usernames 47 | manager.UserValidator = new UserValidator(manager) 48 | { 49 | AllowOnlyAlphanumericUserNames = false, 50 | RequireUniqueEmail = true 51 | }; 52 | 53 | // Configure validation logic for passwords 54 | manager.PasswordValidator = new PasswordValidator 55 | { 56 | RequiredLength = 6, 57 | RequireNonLetterOrDigit = true, 58 | RequireDigit = true, 59 | RequireLowercase = true, 60 | RequireUppercase = true, 61 | }; 62 | 63 | // Configure user lockout defaults 64 | manager.UserLockoutEnabledByDefault = true; 65 | manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5); 66 | manager.MaxFailedAccessAttemptsBeforeLockout = 5; 67 | 68 | // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user 69 | // You can write your own provider and plug it in here. 70 | manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider 71 | { 72 | MessageFormat = "Your security code is {0}" 73 | }); 74 | manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider 75 | { 76 | Subject = "Security Code", 77 | BodyFormat = "Your security code is {0}" 78 | }); 79 | manager.EmailService = new EmailService(); 80 | manager.SmsService = new SmsService(); 81 | var dataProtectionProvider = options.DataProtectionProvider; 82 | if (dataProtectionProvider != null) 83 | { 84 | manager.UserTokenProvider = 85 | new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); 86 | } 87 | return manager; 88 | } 89 | } 90 | 91 | // Configure the application sign-in manager which is used in this application. 92 | public class ApplicationSignInManager : SignInManager 93 | { 94 | public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager) 95 | : base(userManager, authenticationManager) 96 | { 97 | } 98 | 99 | public override Task CreateUserIdentityAsync(ApplicationUser user) 100 | { 101 | return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager); 102 | } 103 | 104 | public static ApplicationSignInManager Create(IdentityFactoryOptions options, IOwinContext context) 105 | { 106 | return new ApplicationSignInManager(context.GetUserManager(), context.Authentication); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /A11_RBS/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace A11_RBS 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /A11_RBS/App_Start/Startup.Auth.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNet.Identity; 3 | using Microsoft.AspNet.Identity.Owin; 4 | using Microsoft.Owin; 5 | using Microsoft.Owin.Security.Cookies; 6 | using Microsoft.Owin.Security.Google; 7 | using Owin; 8 | using A11_RBS.Models; 9 | 10 | namespace A11_RBS 11 | { 12 | public partial class Startup 13 | { 14 | // For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864 15 | public void ConfigureAuth(IAppBuilder app) 16 | { 17 | // Configure the db context, user manager and signin manager to use a single instance per request 18 | app.CreatePerOwinContext(ApplicationDbContext.Create); 19 | app.CreatePerOwinContext(ApplicationUserManager.Create); 20 | app.CreatePerOwinContext(ApplicationSignInManager.Create); 21 | 22 | // Enable the application to use a cookie to store information for the signed in user 23 | // and to use a cookie to temporarily store information about a user logging in with a third party login provider 24 | // Configure the sign in cookie 25 | app.UseCookieAuthentication(new CookieAuthenticationOptions 26 | { 27 | AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 28 | LoginPath = new PathString("/Account/Login"), 29 | Provider = new CookieAuthenticationProvider 30 | { 31 | // Enables the application to validate the security stamp when the user logs in. 32 | // This is a security feature which is used when you change a password or add an external login to your account. 33 | OnValidateIdentity = SecurityStampValidator.OnValidateIdentity( 34 | validateInterval: TimeSpan.FromMinutes(30), 35 | regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) 36 | } 37 | }); 38 | app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 39 | 40 | // Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process. 41 | app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5)); 42 | 43 | // Enables the application to remember the second login verification factor such as phone or email. 44 | // Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from. 45 | // This is similar to the RememberMe option when you log in. 46 | app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie); 47 | 48 | // Uncomment the following lines to enable logging in with third party login providers 49 | //app.UseMicrosoftAccountAuthentication( 50 | // clientId: "", 51 | // clientSecret: ""); 52 | 53 | //app.UseTwitterAuthentication( 54 | // consumerKey: "", 55 | // consumerSecret: ""); 56 | 57 | //app.UseFacebookAuthentication( 58 | // appId: "", 59 | // appSecret: ""); 60 | 61 | //app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 62 | //{ 63 | // ClientId = "", 64 | // ClientSecret = "" 65 | //}); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /A11_RBS/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Override the default bootstrap behavior where horizontal description lists 13 | will truncate terms that are too long to fit in the left column 14 | */ 15 | .dl-horizontal dt { 16 | white-space: normal; 17 | } 18 | 19 | /* Set width on the form input elements since they're 100% wide by default */ 20 | input, 21 | select, 22 | textarea { 23 | max-width: 280px; 24 | } 25 | -------------------------------------------------------------------------------- /A11_RBS/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Threading.Tasks; 6 | using System.Web; 7 | using System.Web.Mvc; 8 | using Microsoft.AspNet.Identity; 9 | using Microsoft.AspNet.Identity.Owin; 10 | using Microsoft.Owin.Security; 11 | using A11_RBS.Models; 12 | 13 | 14 | namespace A11_RBS.Controllers 15 | { 16 | [Authorize] 17 | public class AccountController : Controller 18 | { 19 | private ApplicationSignInManager _signInManager; 20 | private ApplicationUserManager _userManager; 21 | 22 | ApplicationDbContext context; 23 | 24 | 25 | public AccountController() 26 | { 27 | context = new ApplicationDbContext(); 28 | } 29 | 30 | public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager ) 31 | { 32 | UserManager = userManager; 33 | SignInManager = signInManager; 34 | } 35 | 36 | public ApplicationSignInManager SignInManager 37 | { 38 | get 39 | { 40 | return _signInManager ?? HttpContext.GetOwinContext().Get(); 41 | } 42 | private set 43 | { 44 | _signInManager = value; 45 | } 46 | } 47 | 48 | public ApplicationUserManager UserManager 49 | { 50 | get 51 | { 52 | return _userManager ?? HttpContext.GetOwinContext().GetUserManager(); 53 | } 54 | private set 55 | { 56 | _userManager = value; 57 | } 58 | } 59 | 60 | // 61 | // GET: /Account/Login 62 | [AllowAnonymous] 63 | public ActionResult Login(string returnUrl) 64 | { 65 | ViewBag.ReturnUrl = returnUrl; 66 | return View(); 67 | } 68 | 69 | // 70 | // POST: /Account/Login 71 | [HttpPost] 72 | [AllowAnonymous] 73 | [ValidateAntiForgeryToken] 74 | public async Task Login(LoginViewModel model, string returnUrl) 75 | { 76 | if (!ModelState.IsValid) 77 | { 78 | return View(model); 79 | } 80 | 81 | // This doesn't count login failures towards account lockout 82 | // To enable password failures to trigger account lockout, change to shouldLockout: true 83 | var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); 84 | switch (result) 85 | { 86 | case SignInStatus.Success: 87 | return RedirectToLocal(returnUrl); 88 | case SignInStatus.LockedOut: 89 | return View("Lockout"); 90 | case SignInStatus.RequiresVerification: 91 | return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); 92 | case SignInStatus.Failure: 93 | default: 94 | ModelState.AddModelError("", "Invalid login attempt."); 95 | return View(model); 96 | } 97 | } 98 | 99 | // 100 | // GET: /Account/VerifyCode 101 | [AllowAnonymous] 102 | public async Task VerifyCode(string provider, string returnUrl, bool rememberMe) 103 | { 104 | // Require that the user has already logged in via username/password or external login 105 | if (!await SignInManager.HasBeenVerifiedAsync()) 106 | { 107 | return View("Error"); 108 | } 109 | return View(new VerifyCodeViewModel { Provider = provider, ReturnUrl = returnUrl, RememberMe = rememberMe }); 110 | } 111 | 112 | // 113 | // POST: /Account/VerifyCode 114 | [HttpPost] 115 | [AllowAnonymous] 116 | [ValidateAntiForgeryToken] 117 | public async Task VerifyCode(VerifyCodeViewModel model) 118 | { 119 | if (!ModelState.IsValid) 120 | { 121 | return View(model); 122 | } 123 | 124 | // The following code protects for brute force attacks against the two factor codes. 125 | // If a user enters incorrect codes for a specified amount of time then the user account 126 | // will be locked out for a specified amount of time. 127 | // You can configure the account lockout settings in IdentityConfig 128 | var result = await SignInManager.TwoFactorSignInAsync(model.Provider, model.Code, isPersistent: model.RememberMe, rememberBrowser: model.RememberBrowser); 129 | switch (result) 130 | { 131 | case SignInStatus.Success: 132 | return RedirectToLocal(model.ReturnUrl); 133 | case SignInStatus.LockedOut: 134 | return View("Lockout"); 135 | case SignInStatus.Failure: 136 | default: 137 | ModelState.AddModelError("", "Invalid code."); 138 | return View(model); 139 | } 140 | } 141 | 142 | // 143 | // GET: /Account/Register 144 | [AllowAnonymous] 145 | public ActionResult Register() 146 | { 147 | ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name"); 148 | return View(); 149 | } 150 | 151 | // 152 | // POST: /Account/Register 153 | [HttpPost] 154 | [AllowAnonymous] 155 | [ValidateAntiForgeryToken] 156 | public async Task Register(RegisterViewModel model) 157 | { 158 | if (ModelState.IsValid) 159 | { 160 | var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 161 | var result = await UserManager.CreateAsync(user, model.Password); 162 | if (result.Succeeded) 163 | { 164 | 165 | //Assign Role to user Here 166 | await this.UserManager.AddToRoleAsync(user.Id, model.Name); 167 | //Ends Here 168 | 169 | 170 | await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); 171 | 172 | // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 173 | // Send an email with this link 174 | // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); 175 | // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); 176 | // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking here"); 177 | 178 | return RedirectToAction("Index", "Home"); 179 | } 180 | AddErrors(result); 181 | } 182 | 183 | // If we got this far, something failed, redisplay form 184 | return View(model); 185 | } 186 | 187 | // 188 | // GET: /Account/ConfirmEmail 189 | [AllowAnonymous] 190 | public async Task ConfirmEmail(string userId, string code) 191 | { 192 | if (userId == null || code == null) 193 | { 194 | return View("Error"); 195 | } 196 | var result = await UserManager.ConfirmEmailAsync(userId, code); 197 | return View(result.Succeeded ? "ConfirmEmail" : "Error"); 198 | } 199 | 200 | // 201 | // GET: /Account/ForgotPassword 202 | [AllowAnonymous] 203 | public ActionResult ForgotPassword() 204 | { 205 | return View(); 206 | } 207 | 208 | // 209 | // POST: /Account/ForgotPassword 210 | [HttpPost] 211 | [AllowAnonymous] 212 | [ValidateAntiForgeryToken] 213 | public async Task ForgotPassword(ForgotPasswordViewModel model) 214 | { 215 | if (ModelState.IsValid) 216 | { 217 | var user = await UserManager.FindByNameAsync(model.Email); 218 | if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id))) 219 | { 220 | // Don't reveal that the user does not exist or is not confirmed 221 | return View("ForgotPasswordConfirmation"); 222 | } 223 | 224 | // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 225 | // Send an email with this link 226 | // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); 227 | // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); 228 | // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking here"); 229 | // return RedirectToAction("ForgotPasswordConfirmation", "Account"); 230 | } 231 | 232 | // If we got this far, something failed, redisplay form 233 | return View(model); 234 | } 235 | 236 | // 237 | // GET: /Account/ForgotPasswordConfirmation 238 | [AllowAnonymous] 239 | public ActionResult ForgotPasswordConfirmation() 240 | { 241 | return View(); 242 | } 243 | 244 | // 245 | // GET: /Account/ResetPassword 246 | [AllowAnonymous] 247 | public ActionResult ResetPassword(string code) 248 | { 249 | return code == null ? View("Error") : View(); 250 | } 251 | 252 | // 253 | // POST: /Account/ResetPassword 254 | [HttpPost] 255 | [AllowAnonymous] 256 | [ValidateAntiForgeryToken] 257 | public async Task ResetPassword(ResetPasswordViewModel model) 258 | { 259 | if (!ModelState.IsValid) 260 | { 261 | return View(model); 262 | } 263 | var user = await UserManager.FindByNameAsync(model.Email); 264 | if (user == null) 265 | { 266 | // Don't reveal that the user does not exist 267 | return RedirectToAction("ResetPasswordConfirmation", "Account"); 268 | } 269 | var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password); 270 | if (result.Succeeded) 271 | { 272 | return RedirectToAction("ResetPasswordConfirmation", "Account"); 273 | } 274 | AddErrors(result); 275 | return View(); 276 | } 277 | 278 | // 279 | // GET: /Account/ResetPasswordConfirmation 280 | [AllowAnonymous] 281 | public ActionResult ResetPasswordConfirmation() 282 | { 283 | return View(); 284 | } 285 | 286 | // 287 | // POST: /Account/ExternalLogin 288 | [HttpPost] 289 | [AllowAnonymous] 290 | [ValidateAntiForgeryToken] 291 | public ActionResult ExternalLogin(string provider, string returnUrl) 292 | { 293 | // Request a redirect to the external login provider 294 | return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl })); 295 | } 296 | 297 | // 298 | // GET: /Account/SendCode 299 | [AllowAnonymous] 300 | public async Task SendCode(string returnUrl, bool rememberMe) 301 | { 302 | var userId = await SignInManager.GetVerifiedUserIdAsync(); 303 | if (userId == null) 304 | { 305 | return View("Error"); 306 | } 307 | var userFactors = await UserManager.GetValidTwoFactorProvidersAsync(userId); 308 | var factorOptions = userFactors.Select(purpose => new SelectListItem { Text = purpose, Value = purpose }).ToList(); 309 | return View(new SendCodeViewModel { Providers = factorOptions, ReturnUrl = returnUrl, RememberMe = rememberMe }); 310 | } 311 | 312 | // 313 | // POST: /Account/SendCode 314 | [HttpPost] 315 | [AllowAnonymous] 316 | [ValidateAntiForgeryToken] 317 | public async Task SendCode(SendCodeViewModel model) 318 | { 319 | if (!ModelState.IsValid) 320 | { 321 | return View(); 322 | } 323 | 324 | // Generate the token and send it 325 | if (!await SignInManager.SendTwoFactorCodeAsync(model.SelectedProvider)) 326 | { 327 | return View("Error"); 328 | } 329 | return RedirectToAction("VerifyCode", new { Provider = model.SelectedProvider, ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe }); 330 | } 331 | 332 | // 333 | // GET: /Account/ExternalLoginCallback 334 | [AllowAnonymous] 335 | public async Task ExternalLoginCallback(string returnUrl) 336 | { 337 | var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); 338 | if (loginInfo == null) 339 | { 340 | return RedirectToAction("Login"); 341 | } 342 | 343 | // Sign in the user with this external login provider if the user already has a login 344 | var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false); 345 | switch (result) 346 | { 347 | case SignInStatus.Success: 348 | return RedirectToLocal(returnUrl); 349 | case SignInStatus.LockedOut: 350 | return View("Lockout"); 351 | case SignInStatus.RequiresVerification: 352 | return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false }); 353 | case SignInStatus.Failure: 354 | default: 355 | // If the user does not have an account, then prompt the user to create an account 356 | ViewBag.ReturnUrl = returnUrl; 357 | ViewBag.LoginProvider = loginInfo.Login.LoginProvider; 358 | return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email }); 359 | } 360 | } 361 | 362 | // 363 | // POST: /Account/ExternalLoginConfirmation 364 | [HttpPost] 365 | [AllowAnonymous] 366 | [ValidateAntiForgeryToken] 367 | public async Task ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) 368 | { 369 | if (User.Identity.IsAuthenticated) 370 | { 371 | return RedirectToAction("Index", "Manage"); 372 | } 373 | 374 | if (ModelState.IsValid) 375 | { 376 | // Get the information about the user from the external login provider 377 | var info = await AuthenticationManager.GetExternalLoginInfoAsync(); 378 | if (info == null) 379 | { 380 | return View("ExternalLoginFailure"); 381 | } 382 | var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 383 | var result = await UserManager.CreateAsync(user); 384 | if (result.Succeeded) 385 | { 386 | result = await UserManager.AddLoginAsync(user.Id, info.Login); 387 | if (result.Succeeded) 388 | { 389 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 390 | return RedirectToLocal(returnUrl); 391 | } 392 | } 393 | AddErrors(result); 394 | } 395 | 396 | ViewBag.ReturnUrl = returnUrl; 397 | return View(model); 398 | } 399 | 400 | // 401 | // POST: /Account/LogOff 402 | [HttpPost] 403 | [ValidateAntiForgeryToken] 404 | public ActionResult LogOff() 405 | { 406 | AuthenticationManager.SignOut(); 407 | return RedirectToAction("Index", "Home"); 408 | } 409 | 410 | // 411 | // GET: /Account/ExternalLoginFailure 412 | [AllowAnonymous] 413 | public ActionResult ExternalLoginFailure() 414 | { 415 | return View(); 416 | } 417 | 418 | protected override void Dispose(bool disposing) 419 | { 420 | if (disposing) 421 | { 422 | if (_userManager != null) 423 | { 424 | _userManager.Dispose(); 425 | _userManager = null; 426 | } 427 | 428 | if (_signInManager != null) 429 | { 430 | _signInManager.Dispose(); 431 | _signInManager = null; 432 | } 433 | } 434 | 435 | base.Dispose(disposing); 436 | } 437 | 438 | #region Helpers 439 | // Used for XSRF protection when adding external logins 440 | private const string XsrfKey = "XsrfId"; 441 | 442 | private IAuthenticationManager AuthenticationManager 443 | { 444 | get 445 | { 446 | return HttpContext.GetOwinContext().Authentication; 447 | } 448 | } 449 | 450 | private void AddErrors(IdentityResult result) 451 | { 452 | foreach (var error in result.Errors) 453 | { 454 | ModelState.AddModelError("", error); 455 | } 456 | } 457 | 458 | private ActionResult RedirectToLocal(string returnUrl) 459 | { 460 | if (Url.IsLocalUrl(returnUrl)) 461 | { 462 | return Redirect(returnUrl); 463 | } 464 | return RedirectToAction("Index", "Home"); 465 | } 466 | 467 | internal class ChallengeResult : HttpUnauthorizedResult 468 | { 469 | public ChallengeResult(string provider, string redirectUri) 470 | : this(provider, redirectUri, null) 471 | { 472 | } 473 | 474 | public ChallengeResult(string provider, string redirectUri, string userId) 475 | { 476 | LoginProvider = provider; 477 | RedirectUri = redirectUri; 478 | UserId = userId; 479 | } 480 | 481 | public string LoginProvider { get; set; } 482 | public string RedirectUri { get; set; } 483 | public string UserId { get; set; } 484 | 485 | public override void ExecuteResult(ControllerContext context) 486 | { 487 | var properties = new AuthenticationProperties { RedirectUri = RedirectUri }; 488 | if (UserId != null) 489 | { 490 | properties.Dictionary[XsrfKey] = UserId; 491 | } 492 | context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider); 493 | } 494 | } 495 | #endregion 496 | } 497 | } -------------------------------------------------------------------------------- /A11_RBS/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | namespace A11_RBS.Controllers 8 | { 9 | public class HomeController : Controller 10 | { 11 | public ActionResult Index() 12 | { 13 | return View(); 14 | } 15 | 16 | public ActionResult About() 17 | { 18 | ViewBag.Message = "Your application description page."; 19 | 20 | return View(); 21 | } 22 | 23 | public ActionResult Contact() 24 | { 25 | ViewBag.Message = "Your contact page."; 26 | 27 | return View(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /A11_RBS/Controllers/ManageController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using Microsoft.AspNet.Identity; 7 | using Microsoft.AspNet.Identity.Owin; 8 | using Microsoft.Owin.Security; 9 | using A11_RBS.Models; 10 | 11 | namespace A11_RBS.Controllers 12 | { 13 | [Authorize] 14 | public class ManageController : Controller 15 | { 16 | private ApplicationSignInManager _signInManager; 17 | private ApplicationUserManager _userManager; 18 | 19 | public ManageController() 20 | { 21 | } 22 | 23 | public ManageController(ApplicationUserManager userManager, ApplicationSignInManager signInManager) 24 | { 25 | UserManager = userManager; 26 | SignInManager = signInManager; 27 | } 28 | 29 | public ApplicationSignInManager SignInManager 30 | { 31 | get 32 | { 33 | return _signInManager ?? HttpContext.GetOwinContext().Get(); 34 | } 35 | private set 36 | { 37 | _signInManager = value; 38 | } 39 | } 40 | 41 | public ApplicationUserManager UserManager 42 | { 43 | get 44 | { 45 | return _userManager ?? HttpContext.GetOwinContext().GetUserManager(); 46 | } 47 | private set 48 | { 49 | _userManager = value; 50 | } 51 | } 52 | 53 | // 54 | // GET: /Manage/Index 55 | public async Task Index(ManageMessageId? message) 56 | { 57 | ViewBag.StatusMessage = 58 | message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed." 59 | : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set." 60 | : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set." 61 | : message == ManageMessageId.Error ? "An error has occurred." 62 | : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added." 63 | : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed." 64 | : ""; 65 | 66 | var userId = User.Identity.GetUserId(); 67 | var model = new IndexViewModel 68 | { 69 | HasPassword = HasPassword(), 70 | PhoneNumber = await UserManager.GetPhoneNumberAsync(userId), 71 | TwoFactor = await UserManager.GetTwoFactorEnabledAsync(userId), 72 | Logins = await UserManager.GetLoginsAsync(userId), 73 | BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId) 74 | }; 75 | return View(model); 76 | } 77 | 78 | // 79 | // POST: /Manage/RemoveLogin 80 | [HttpPost] 81 | [ValidateAntiForgeryToken] 82 | public async Task RemoveLogin(string loginProvider, string providerKey) 83 | { 84 | ManageMessageId? message; 85 | var result = await UserManager.RemoveLoginAsync(User.Identity.GetUserId(), new UserLoginInfo(loginProvider, providerKey)); 86 | if (result.Succeeded) 87 | { 88 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 89 | if (user != null) 90 | { 91 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 92 | } 93 | message = ManageMessageId.RemoveLoginSuccess; 94 | } 95 | else 96 | { 97 | message = ManageMessageId.Error; 98 | } 99 | return RedirectToAction("ManageLogins", new { Message = message }); 100 | } 101 | 102 | // 103 | // GET: /Manage/AddPhoneNumber 104 | public ActionResult AddPhoneNumber() 105 | { 106 | return View(); 107 | } 108 | 109 | // 110 | // POST: /Manage/AddPhoneNumber 111 | [HttpPost] 112 | [ValidateAntiForgeryToken] 113 | public async Task AddPhoneNumber(AddPhoneNumberViewModel model) 114 | { 115 | if (!ModelState.IsValid) 116 | { 117 | return View(model); 118 | } 119 | // Generate the token and send it 120 | var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number); 121 | if (UserManager.SmsService != null) 122 | { 123 | var message = new IdentityMessage 124 | { 125 | Destination = model.Number, 126 | Body = "Your security code is: " + code 127 | }; 128 | await UserManager.SmsService.SendAsync(message); 129 | } 130 | return RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number }); 131 | } 132 | 133 | // 134 | // POST: /Manage/EnableTwoFactorAuthentication 135 | [HttpPost] 136 | [ValidateAntiForgeryToken] 137 | public async Task EnableTwoFactorAuthentication() 138 | { 139 | await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), true); 140 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 141 | if (user != null) 142 | { 143 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 144 | } 145 | return RedirectToAction("Index", "Manage"); 146 | } 147 | 148 | // 149 | // POST: /Manage/DisableTwoFactorAuthentication 150 | [HttpPost] 151 | [ValidateAntiForgeryToken] 152 | public async Task DisableTwoFactorAuthentication() 153 | { 154 | await UserManager.SetTwoFactorEnabledAsync(User.Identity.GetUserId(), false); 155 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 156 | if (user != null) 157 | { 158 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 159 | } 160 | return RedirectToAction("Index", "Manage"); 161 | } 162 | 163 | // 164 | // GET: /Manage/VerifyPhoneNumber 165 | public async Task VerifyPhoneNumber(string phoneNumber) 166 | { 167 | var code = await UserManager.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), phoneNumber); 168 | // Send an SMS through the SMS provider to verify the phone number 169 | return phoneNumber == null ? View("Error") : View(new VerifyPhoneNumberViewModel { PhoneNumber = phoneNumber }); 170 | } 171 | 172 | // 173 | // POST: /Manage/VerifyPhoneNumber 174 | [HttpPost] 175 | [ValidateAntiForgeryToken] 176 | public async Task VerifyPhoneNumber(VerifyPhoneNumberViewModel model) 177 | { 178 | if (!ModelState.IsValid) 179 | { 180 | return View(model); 181 | } 182 | var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code); 183 | if (result.Succeeded) 184 | { 185 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 186 | if (user != null) 187 | { 188 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 189 | } 190 | return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess }); 191 | } 192 | // If we got this far, something failed, redisplay form 193 | ModelState.AddModelError("", "Failed to verify phone"); 194 | return View(model); 195 | } 196 | 197 | // 198 | // GET: /Manage/RemovePhoneNumber 199 | public async Task RemovePhoneNumber() 200 | { 201 | var result = await UserManager.SetPhoneNumberAsync(User.Identity.GetUserId(), null); 202 | if (!result.Succeeded) 203 | { 204 | return RedirectToAction("Index", new { Message = ManageMessageId.Error }); 205 | } 206 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 207 | if (user != null) 208 | { 209 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 210 | } 211 | return RedirectToAction("Index", new { Message = ManageMessageId.RemovePhoneSuccess }); 212 | } 213 | 214 | // 215 | // GET: /Manage/ChangePassword 216 | public ActionResult ChangePassword() 217 | { 218 | return View(); 219 | } 220 | 221 | // 222 | // POST: /Manage/ChangePassword 223 | [HttpPost] 224 | [ValidateAntiForgeryToken] 225 | public async Task ChangePassword(ChangePasswordViewModel model) 226 | { 227 | if (!ModelState.IsValid) 228 | { 229 | return View(model); 230 | } 231 | var result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); 232 | if (result.Succeeded) 233 | { 234 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 235 | if (user != null) 236 | { 237 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 238 | } 239 | return RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess }); 240 | } 241 | AddErrors(result); 242 | return View(model); 243 | } 244 | 245 | // 246 | // GET: /Manage/SetPassword 247 | public ActionResult SetPassword() 248 | { 249 | return View(); 250 | } 251 | 252 | // 253 | // POST: /Manage/SetPassword 254 | [HttpPost] 255 | [ValidateAntiForgeryToken] 256 | public async Task SetPassword(SetPasswordViewModel model) 257 | { 258 | if (ModelState.IsValid) 259 | { 260 | var result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword); 261 | if (result.Succeeded) 262 | { 263 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 264 | if (user != null) 265 | { 266 | await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); 267 | } 268 | return RedirectToAction("Index", new { Message = ManageMessageId.SetPasswordSuccess }); 269 | } 270 | AddErrors(result); 271 | } 272 | 273 | // If we got this far, something failed, redisplay form 274 | return View(model); 275 | } 276 | 277 | // 278 | // GET: /Manage/ManageLogins 279 | public async Task ManageLogins(ManageMessageId? message) 280 | { 281 | ViewBag.StatusMessage = 282 | message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed." 283 | : message == ManageMessageId.Error ? "An error has occurred." 284 | : ""; 285 | var user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); 286 | if (user == null) 287 | { 288 | return View("Error"); 289 | } 290 | var userLogins = await UserManager.GetLoginsAsync(User.Identity.GetUserId()); 291 | var otherLogins = AuthenticationManager.GetExternalAuthenticationTypes().Where(auth => userLogins.All(ul => auth.AuthenticationType != ul.LoginProvider)).ToList(); 292 | ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count > 1; 293 | return View(new ManageLoginsViewModel 294 | { 295 | CurrentLogins = userLogins, 296 | OtherLogins = otherLogins 297 | }); 298 | } 299 | 300 | // 301 | // POST: /Manage/LinkLogin 302 | [HttpPost] 303 | [ValidateAntiForgeryToken] 304 | public ActionResult LinkLogin(string provider) 305 | { 306 | // Request a redirect to the external login provider to link a login for the current user 307 | return new AccountController.ChallengeResult(provider, Url.Action("LinkLoginCallback", "Manage"), User.Identity.GetUserId()); 308 | } 309 | 310 | // 311 | // GET: /Manage/LinkLoginCallback 312 | public async Task LinkLoginCallback() 313 | { 314 | var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, User.Identity.GetUserId()); 315 | if (loginInfo == null) 316 | { 317 | return RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error }); 318 | } 319 | var result = await UserManager.AddLoginAsync(User.Identity.GetUserId(), loginInfo.Login); 320 | return result.Succeeded ? RedirectToAction("ManageLogins") : RedirectToAction("ManageLogins", new { Message = ManageMessageId.Error }); 321 | } 322 | 323 | protected override void Dispose(bool disposing) 324 | { 325 | if (disposing && _userManager != null) 326 | { 327 | _userManager.Dispose(); 328 | _userManager = null; 329 | } 330 | 331 | base.Dispose(disposing); 332 | } 333 | 334 | #region Helpers 335 | // Used for XSRF protection when adding external logins 336 | private const string XsrfKey = "XsrfId"; 337 | 338 | private IAuthenticationManager AuthenticationManager 339 | { 340 | get 341 | { 342 | return HttpContext.GetOwinContext().Authentication; 343 | } 344 | } 345 | 346 | private void AddErrors(IdentityResult result) 347 | { 348 | foreach (var error in result.Errors) 349 | { 350 | ModelState.AddModelError("", error); 351 | } 352 | } 353 | 354 | private bool HasPassword() 355 | { 356 | var user = UserManager.FindById(User.Identity.GetUserId()); 357 | if (user != null) 358 | { 359 | return user.PasswordHash != null; 360 | } 361 | return false; 362 | } 363 | 364 | private bool HasPhoneNumber() 365 | { 366 | var user = UserManager.FindById(User.Identity.GetUserId()); 367 | if (user != null) 368 | { 369 | return user.PhoneNumber != null; 370 | } 371 | return false; 372 | } 373 | 374 | public enum ManageMessageId 375 | { 376 | AddPhoneSuccess, 377 | ChangePasswordSuccess, 378 | SetTwoFactorSuccess, 379 | SetPasswordSuccess, 380 | RemoveLoginSuccess, 381 | RemovePhoneSuccess, 382 | Error 383 | } 384 | 385 | #endregion 386 | } 387 | } -------------------------------------------------------------------------------- /A11_RBS/Controllers/ProductController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | 7 | using A11_RBS.Models; 8 | using A11_RBS.CustomFilters; 9 | 10 | 11 | namespace A11_RBS.Controllers 12 | { 13 | public class ProductController : Controller 14 | { 15 | SuperMarketEntities ctx; 16 | 17 | public ProductController() 18 | { 19 | ctx = new SuperMarketEntities(); 20 | } 21 | 22 | // GET: Product 23 | public ActionResult Index() 24 | { 25 | var Products = ctx.ProductMasters.ToList(); 26 | return View(Products); 27 | } 28 | 29 | [AuthLog(Roles = "Manager")] 30 | public ActionResult Create() 31 | { 32 | var Product = new ProductMaster(); 33 | return View(Product); 34 | } 35 | 36 | 37 | 38 | 39 | [HttpPost] 40 | public ActionResult Create(ProductMaster p) 41 | { 42 | ctx.ProductMasters.Add(p); 43 | ctx.SaveChanges(); 44 | return RedirectToAction("Index"); 45 | } 46 | 47 | [AuthLog(Roles = "Sales Executive")] 48 | public ActionResult SaleProduct() 49 | { 50 | ViewBag.Message = "This View is designed for the Sales Executive to Sale Product."; 51 | return View(); 52 | } 53 | 54 | } 55 | } -------------------------------------------------------------------------------- /A11_RBS/Controllers/RoleController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Web.Mvc; 4 | 5 | using A11_RBS.Models; 6 | using Microsoft.AspNet.Identity.EntityFramework; 7 | 8 | namespace A11_RBS.Controllers 9 | { 10 | public class RoleController : Controller 11 | { 12 | ApplicationDbContext context; 13 | 14 | public RoleController() 15 | { 16 | context = new ApplicationDbContext(); 17 | } 18 | 19 | 20 | 21 | /// 22 | /// Get All Roles 23 | /// 24 | /// 25 | public ActionResult Index() 26 | { 27 | var Roles = context.Roles.ToList(); 28 | return View(Roles); 29 | } 30 | 31 | /// 32 | /// Create a New role 33 | /// 34 | /// 35 | public ActionResult Create() 36 | { 37 | var Role = new IdentityRole(); 38 | return View(Role); 39 | } 40 | 41 | /// 42 | /// Create a New Role 43 | /// 44 | /// 45 | /// 46 | [HttpPost] 47 | public ActionResult Create(IdentityRole Role) 48 | { 49 | 50 | context.Roles.Add(Role); 51 | context.SaveChanges(); 52 | return RedirectToAction("Index"); 53 | } 54 | 55 | /// 56 | /// Set Role for Users 57 | /// 58 | /// 59 | public ActionResult SetRoleToUser() 60 | { 61 | var list = context.Roles.OrderBy(role => role.Name).ToList().Select(role => new SelectListItem { Value = role.Name.ToString(), Text = role.Name }).ToList(); 62 | ViewBag.Roles = list; 63 | return View(); 64 | } 65 | 66 | [HttpPost] 67 | [ValidateAntiForgeryToken] 68 | public ActionResult UserAddToRole(string uname, string rolename) 69 | { 70 | ApplicationUser user = context.Users.Where(usr => usr.UserName.Equals(uname, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault(); 71 | 72 | // Display All Roles in DropDown 73 | 74 | var list = context.Roles.OrderBy(role => role.Name).ToList().Select(role => new SelectListItem { Value = role.Name.ToString(), Text = role.Name }).ToList(); 75 | ViewBag.Roles = list; 76 | 77 | if (user != null) 78 | { 79 | var account = new AccountController(); 80 | account.UserManager.AddToRoleAsync(user.Id, rolename); 81 | 82 | ViewBag.ResultMessage = "Role created successfully !"; 83 | 84 | return View("SetRoleToUser"); 85 | } 86 | else 87 | { 88 | ViewBag.ErrorMessage = "Sorry user is not available"; 89 | return View("SetRoleToUser"); 90 | } 91 | 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /A11_RBS/CustomFilters/LogAuthFilter.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | 3 | namespace A11_RBS.CustomFilters 4 | { 5 | public class AuthLogAttribute : AuthorizeAttribute 6 | { 7 | public AuthLogAttribute() 8 | { 9 | View = "AuthorizeFailed"; 10 | } 11 | 12 | public string View { get; set; } 13 | 14 | /// 15 | /// Check for Authorization 16 | /// 17 | /// 18 | public override void OnAuthorization(AuthorizationContext filterContext) 19 | { 20 | base.OnAuthorization(filterContext); 21 | IsUserAuthorized(filterContext); 22 | } 23 | 24 | /// 25 | /// Method to check if the user is Authorized or not 26 | /// if yes continue to perform the action else redirect to error page 27 | /// 28 | /// 29 | private void IsUserAuthorized(AuthorizationContext filterContext) 30 | { 31 | // If the Result returns null then the user is Authorized 32 | if (filterContext.Result == null) 33 | return; 34 | 35 | //If the user is Un-Authorized then Navigate to Auth Failed View 36 | if (filterContext.HttpContext.User.Identity.IsAuthenticated) 37 | { 38 | 39 | // var result = new ViewResult { ViewName = View }; 40 | var vr = new ViewResult(); 41 | vr.ViewName = View; 42 | 43 | ViewDataDictionary dict = new ViewDataDictionary(); 44 | dict.Add("Message", "Sorry you are not Authorized to Perform this Action"); 45 | 46 | vr.ViewData = dict; 47 | 48 | var result = vr; 49 | 50 | filterContext.Result = result; 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /A11_RBS/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="A11_RBS.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /A11_RBS/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Optimization; 7 | using System.Web.Routing; 8 | 9 | namespace A11_RBS 10 | { 11 | public class MvcApplication : System.Web.HttpApplication 12 | { 13 | protected void Application_Start() 14 | { 15 | AreaRegistration.RegisterAllAreas(); 16 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 17 | RouteConfig.RegisterRoutes(RouteTable.Routes); 18 | BundleConfig.RegisterBundles(BundleTable.Bundles); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /A11_RBS/Models/AccountViewModels.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace A11_RBS.Models 5 | { 6 | public class ExternalLoginConfirmationViewModel 7 | { 8 | [Required] 9 | [Display(Name = "Email")] 10 | public string Email { get; set; } 11 | } 12 | 13 | public class ExternalLoginListViewModel 14 | { 15 | public string ReturnUrl { get; set; } 16 | } 17 | 18 | public class SendCodeViewModel 19 | { 20 | public string SelectedProvider { get; set; } 21 | public ICollection Providers { get; set; } 22 | public string ReturnUrl { get; set; } 23 | public bool RememberMe { get; set; } 24 | } 25 | 26 | public class VerifyCodeViewModel 27 | { 28 | [Required] 29 | public string Provider { get; set; } 30 | 31 | [Required] 32 | [Display(Name = "Code")] 33 | public string Code { get; set; } 34 | public string ReturnUrl { get; set; } 35 | 36 | [Display(Name = "Remember this browser?")] 37 | public bool RememberBrowser { get; set; } 38 | 39 | public bool RememberMe { get; set; } 40 | } 41 | 42 | public class ForgotViewModel 43 | { 44 | [Required] 45 | [Display(Name = "Email")] 46 | public string Email { get; set; } 47 | } 48 | 49 | public class LoginViewModel 50 | { 51 | [Required] 52 | [Display(Name = "Email")] 53 | [EmailAddress] 54 | public string Email { get; set; } 55 | 56 | [Required] 57 | [DataType(DataType.Password)] 58 | [Display(Name = "Password")] 59 | public string Password { get; set; } 60 | 61 | [Display(Name = "Remember me?")] 62 | public bool RememberMe { get; set; } 63 | } 64 | 65 | public class RegisterViewModel 66 | { 67 | [Required] 68 | [EmailAddress] 69 | [Display(Name = "Email")] 70 | public string Email { get; set; } 71 | 72 | [Required] 73 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 74 | [DataType(DataType.Password)] 75 | [Display(Name = "Password")] 76 | public string Password { get; set; } 77 | 78 | [DataType(DataType.Password)] 79 | [Display(Name = "Confirm password")] 80 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 81 | public string ConfirmPassword { get; set; } 82 | 83 | public string Name { get; set; } 84 | } 85 | 86 | public class ResetPasswordViewModel 87 | { 88 | [Required] 89 | [EmailAddress] 90 | [Display(Name = "Email")] 91 | public string Email { get; set; } 92 | 93 | [Required] 94 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 95 | [DataType(DataType.Password)] 96 | [Display(Name = "Password")] 97 | public string Password { get; set; } 98 | 99 | [DataType(DataType.Password)] 100 | [Display(Name = "Confirm password")] 101 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 102 | public string ConfirmPassword { get; set; } 103 | 104 | public string Code { get; set; } 105 | } 106 | 107 | public class ForgotPasswordViewModel 108 | { 109 | [Required] 110 | [EmailAddress] 111 | [Display(Name = "Email")] 112 | public string Email { get; set; } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /A11_RBS/Models/IdentityModels.cs: -------------------------------------------------------------------------------- 1 | using System.Data.Entity; 2 | using System.Security.Claims; 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNet.Identity; 5 | using Microsoft.AspNet.Identity.EntityFramework; 6 | 7 | namespace A11_RBS.Models 8 | { 9 | // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. 10 | public class ApplicationUser : IdentityUser 11 | { 12 | public async Task GenerateUserIdentityAsync(UserManager manager) 13 | { 14 | // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType 15 | var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); 16 | // Add custom user claims here 17 | return userIdentity; 18 | } 19 | } 20 | 21 | public class ApplicationDbContext : IdentityDbContext 22 | { 23 | public ApplicationDbContext() 24 | : base("DefaultConnection", throwIfV1Schema: false) 25 | { 26 | } 27 | 28 | public static ApplicationDbContext Create() 29 | { 30 | return new ApplicationDbContext(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /A11_RBS/Models/ManageViewModels.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | using Microsoft.AspNet.Identity; 4 | using Microsoft.Owin.Security; 5 | 6 | namespace A11_RBS.Models 7 | { 8 | public class IndexViewModel 9 | { 10 | public bool HasPassword { get; set; } 11 | public IList Logins { get; set; } 12 | public string PhoneNumber { get; set; } 13 | public bool TwoFactor { get; set; } 14 | public bool BrowserRemembered { get; set; } 15 | } 16 | 17 | public class ManageLoginsViewModel 18 | { 19 | public IList CurrentLogins { get; set; } 20 | public IList OtherLogins { get; set; } 21 | } 22 | 23 | public class FactorViewModel 24 | { 25 | public string Purpose { get; set; } 26 | } 27 | 28 | public class SetPasswordViewModel 29 | { 30 | [Required] 31 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 32 | [DataType(DataType.Password)] 33 | [Display(Name = "New password")] 34 | public string NewPassword { get; set; } 35 | 36 | [DataType(DataType.Password)] 37 | [Display(Name = "Confirm new password")] 38 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 39 | public string ConfirmPassword { get; set; } 40 | } 41 | 42 | public class ChangePasswordViewModel 43 | { 44 | [Required] 45 | [DataType(DataType.Password)] 46 | [Display(Name = "Current password")] 47 | public string OldPassword { get; set; } 48 | 49 | [Required] 50 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 51 | [DataType(DataType.Password)] 52 | [Display(Name = "New password")] 53 | public string NewPassword { get; set; } 54 | 55 | [DataType(DataType.Password)] 56 | [Display(Name = "Confirm new password")] 57 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 58 | public string ConfirmPassword { get; set; } 59 | } 60 | 61 | public class AddPhoneNumberViewModel 62 | { 63 | [Required] 64 | [Phone] 65 | [Display(Name = "Phone Number")] 66 | public string Number { get; set; } 67 | } 68 | 69 | public class VerifyPhoneNumberViewModel 70 | { 71 | [Required] 72 | [Display(Name = "Code")] 73 | public string Code { get; set; } 74 | 75 | [Required] 76 | [Phone] 77 | [Display(Name = "Phone Number")] 78 | public string PhoneNumber { get; set; } 79 | } 80 | 81 | public class ConfigureTwoFactorViewModel 82 | { 83 | public string SelectedProvider { get; set; } 84 | public ICollection Providers { get; set; } 85 | } 86 | } -------------------------------------------------------------------------------- /A11_RBS/Models/ProductMaster.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace A11_RBS.Models 11 | { 12 | using System; 13 | using System.Collections.Generic; 14 | 15 | public partial class ProductMaster 16 | { 17 | public int ProductId { get; set; } 18 | public string ProductName { get; set; } 19 | public string Price { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /A11_RBS/Models/SuperMarketEDMX.Context.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace A11_RBS.Models 11 | { 12 | using System; 13 | using System.Data.Entity; 14 | using System.Data.Entity.Infrastructure; 15 | 16 | public partial class SuperMarketEntities : DbContext 17 | { 18 | public SuperMarketEntities() 19 | : base("name=SuperMarketEntities") 20 | { 21 | } 22 | 23 | protected override void OnModelCreating(DbModelBuilder modelBuilder) 24 | { 25 | throw new UnintentionalCodeFirstException(); 26 | } 27 | 28 | public virtual DbSet ProductMasters { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /A11_RBS/Models/SuperMarketEDMX.Designer.cs: -------------------------------------------------------------------------------- 1 | // T4 code generation is enabled for model 'F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\Models\SuperMarketEDMX.edmx'. 2 | // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer 3 | // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model 4 | // is open in the designer. 5 | 6 | // If no context and entity classes have been generated, it may be because you created an empty model but 7 | // have not yet chosen which version of Entity Framework to use. To generate a context class and entity 8 | // classes for your model, open the model in the designer, right-click on the designer surface, and 9 | // select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation 10 | // Item...'. -------------------------------------------------------------------------------- /A11_RBS/Models/SuperMarketEDMX.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated from a template. 4 | // 5 | // Manual changes to this file may cause unexpected behavior in your application. 6 | // Manual changes to this file will be overwritten if the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | -------------------------------------------------------------------------------- /A11_RBS/Models/SuperMarketEDMX.edmx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /A11_RBS/Models/SuperMarketEDMX.edmx.diagram: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /A11_RBS/Models/UnAuthorizeModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.Routing; 7 | 8 | namespace A11_RBS.Models 9 | { 10 | public class AuthorizationFailed 11 | { 12 | public string Message { get; set; } 13 | public RouteData RouteData { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /A11_RBS/Project_Readme.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Your ASP.NET application 6 | 95 | 96 | 97 | 98 | 102 | 103 |
104 |
105 |

This application consists of:

106 |
    107 |
  • Sample pages showing basic nav between Home, About, and Contact
  • 108 |
  • Theming using Bootstrap
  • 109 |
  • Authentication, if selected, shows how to register and sign in
  • 110 |
  • ASP.NET features managed using NuGet
  • 111 |
112 |
113 | 114 | 131 | 132 |
133 |

Deploy

134 | 139 |
140 | 141 |
142 |

Get help

143 | 147 |
148 |
149 | 150 | 151 | -------------------------------------------------------------------------------- /A11_RBS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("A11_RBS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("A11_RBS")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("626bc40e-beb1-4cca-bb8b-07cf6198997f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /A11_RBS/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/Scripts/_references.js -------------------------------------------------------------------------------- /A11_RBS/Scripts/jquery.validate.unobtrusive.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | 20 | /*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ 21 | /*global document: false, jQuery: false */ 22 | 23 | (function ($) { 24 | var $jQval = $.validator, 25 | adapters, 26 | data_validation = "unobtrusiveValidation"; 27 | 28 | function setValidationValues(options, ruleName, value) { 29 | options.rules[ruleName] = value; 30 | if (options.message) { 31 | options.messages[ruleName] = options.message; 32 | } 33 | } 34 | 35 | function splitAndTrim(value) { 36 | return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); 37 | } 38 | 39 | function escapeAttributeValue(value) { 40 | // As mentioned on http://api.jquery.com/category/selectors/ 41 | return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1"); 42 | } 43 | 44 | function getModelPrefix(fieldName) { 45 | return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); 46 | } 47 | 48 | function appendModelPrefix(value, prefix) { 49 | if (value.indexOf("*.") === 0) { 50 | value = value.replace("*.", prefix); 51 | } 52 | return value; 53 | } 54 | 55 | function onError(error, inputElement) { // 'this' is the form element 56 | var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"), 57 | replaceAttrValue = container.attr("data-valmsg-replace"), 58 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null; 59 | 60 | container.removeClass("field-validation-valid").addClass("field-validation-error"); 61 | error.data("unobtrusiveContainer", container); 62 | 63 | if (replace) { 64 | container.empty(); 65 | error.removeClass("input-validation-error").appendTo(container); 66 | } 67 | else { 68 | error.hide(); 69 | } 70 | } 71 | 72 | function onErrors(event, validator) { // 'this' is the form element 73 | var container = $(this).find("[data-valmsg-summary=true]"), 74 | list = container.find("ul"); 75 | 76 | if (list && list.length && validator.errorList.length) { 77 | list.empty(); 78 | container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); 79 | 80 | $.each(validator.errorList, function () { 81 | $("
  • ").html(this.message).appendTo(list); 82 | }); 83 | } 84 | } 85 | 86 | function onSuccess(error) { // 'this' is the form element 87 | var container = error.data("unobtrusiveContainer"), 88 | replaceAttrValue = container.attr("data-valmsg-replace"), 89 | replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null; 90 | 91 | if (container) { 92 | container.addClass("field-validation-valid").removeClass("field-validation-error"); 93 | error.removeData("unobtrusiveContainer"); 94 | 95 | if (replace) { 96 | container.empty(); 97 | } 98 | } 99 | } 100 | 101 | function onReset(event) { // 'this' is the form element 102 | var $form = $(this); 103 | $form.data("validator").resetForm(); 104 | $form.find(".validation-summary-errors") 105 | .addClass("validation-summary-valid") 106 | .removeClass("validation-summary-errors"); 107 | $form.find(".field-validation-error") 108 | .addClass("field-validation-valid") 109 | .removeClass("field-validation-error") 110 | .removeData("unobtrusiveContainer") 111 | .find(">*") // If we were using valmsg-replace, get the underlying error 112 | .removeData("unobtrusiveContainer"); 113 | } 114 | 115 | function validationInfo(form) { 116 | var $form = $(form), 117 | result = $form.data(data_validation), 118 | onResetProxy = $.proxy(onReset, form), 119 | defaultOptions = $jQval.unobtrusive.options || {}, 120 | execInContext = function (name, args) { 121 | var func = defaultOptions[name]; 122 | func && $.isFunction(func) && func.apply(form, args); 123 | } 124 | 125 | if (!result) { 126 | result = { 127 | options: { // options structure passed to jQuery Validate's validate() method 128 | errorClass: defaultOptions.errorClass || "input-validation-error", 129 | errorElement: defaultOptions.errorElement || "span", 130 | errorPlacement: function () { 131 | onError.apply(form, arguments); 132 | execInContext("errorPlacement", arguments); 133 | }, 134 | invalidHandler: function () { 135 | onErrors.apply(form, arguments); 136 | execInContext("invalidHandler", arguments); 137 | }, 138 | messages: {}, 139 | rules: {}, 140 | success: function () { 141 | onSuccess.apply(form, arguments); 142 | execInContext("success", arguments); 143 | } 144 | }, 145 | attachValidation: function () { 146 | $form 147 | .off("reset." + data_validation, onResetProxy) 148 | .on("reset." + data_validation, onResetProxy) 149 | .validate(this.options); 150 | }, 151 | validate: function () { // a validation function that is called by unobtrusive Ajax 152 | $form.validate(); 153 | return $form.valid(); 154 | } 155 | }; 156 | $form.data(data_validation, result); 157 | } 158 | 159 | return result; 160 | } 161 | 162 | $jQval.unobtrusive = { 163 | adapters: [], 164 | 165 | parseElement: function (element, skipAttach) { 166 | /// 167 | /// Parses a single HTML element for unobtrusive validation attributes. 168 | /// 169 | /// The HTML element to be parsed. 170 | /// [Optional] true to skip attaching the 171 | /// validation to the form. If parsing just this single element, you should specify true. 172 | /// If parsing several elements, you should specify false, and manually attach the validation 173 | /// to the form when you are finished. The default is false. 174 | var $element = $(element), 175 | form = $element.parents("form")[0], 176 | valInfo, rules, messages; 177 | 178 | if (!form) { // Cannot do client-side validation without a form 179 | return; 180 | } 181 | 182 | valInfo = validationInfo(form); 183 | valInfo.options.rules[element.name] = rules = {}; 184 | valInfo.options.messages[element.name] = messages = {}; 185 | 186 | $.each(this.adapters, function () { 187 | var prefix = "data-val-" + this.name, 188 | message = $element.attr(prefix), 189 | paramValues = {}; 190 | 191 | if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy) 192 | prefix += "-"; 193 | 194 | $.each(this.params, function () { 195 | paramValues[this] = $element.attr(prefix + this); 196 | }); 197 | 198 | this.adapt({ 199 | element: element, 200 | form: form, 201 | message: message, 202 | params: paramValues, 203 | rules: rules, 204 | messages: messages 205 | }); 206 | } 207 | }); 208 | 209 | $.extend(rules, { "__dummy__": true }); 210 | 211 | if (!skipAttach) { 212 | valInfo.attachValidation(); 213 | } 214 | }, 215 | 216 | parse: function (selector) { 217 | /// 218 | /// Parses all the HTML elements in the specified selector. It looks for input elements decorated 219 | /// with the [data-val=true] attribute value and enables validation according to the data-val-* 220 | /// attribute values. 221 | /// 222 | /// Any valid jQuery selector. 223 | 224 | // $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one 225 | // element with data-val=true 226 | var $selector = $(selector), 227 | $forms = $selector.parents() 228 | .addBack() 229 | .filter("form") 230 | .add($selector.find("form")) 231 | .has("[data-val=true]"); 232 | 233 | $selector.find("[data-val=true]").each(function () { 234 | $jQval.unobtrusive.parseElement(this, true); 235 | }); 236 | 237 | $forms.each(function () { 238 | var info = validationInfo(this); 239 | if (info) { 240 | info.attachValidation(); 241 | } 242 | }); 243 | } 244 | }; 245 | 246 | adapters = $jQval.unobtrusive.adapters; 247 | 248 | adapters.add = function (adapterName, params, fn) { 249 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation. 250 | /// The name of the adapter to be added. This matches the name used 251 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 252 | /// [Optional] An array of parameter names (strings) that will 253 | /// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and 254 | /// mmmm is the parameter name). 255 | /// The function to call, which adapts the values from the HTML 256 | /// attributes into jQuery Validate rules and/or messages. 257 | /// 258 | if (!fn) { // Called with no params, just a function 259 | fn = params; 260 | params = []; 261 | } 262 | this.push({ name: adapterName, params: params, adapt: fn }); 263 | return this; 264 | }; 265 | 266 | adapters.addBool = function (adapterName, ruleName) { 267 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 268 | /// the jQuery Validate validation rule has no parameter values. 269 | /// The name of the adapter to be added. This matches the name used 270 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 271 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 272 | /// of adapterName will be used instead. 273 | /// 274 | return this.add(adapterName, function (options) { 275 | setValidationValues(options, ruleName || adapterName, true); 276 | }); 277 | }; 278 | 279 | adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { 280 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 281 | /// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and 282 | /// one for min-and-max). The HTML parameters are expected to be named -min and -max. 283 | /// The name of the adapter to be added. This matches the name used 284 | /// in the data-val-nnnn HTML attribute (where nnnn is the adapter name). 285 | /// The name of the jQuery Validate rule to be used when you only 286 | /// have a minimum value. 287 | /// The name of the jQuery Validate rule to be used when you only 288 | /// have a maximum value. 289 | /// The name of the jQuery Validate rule to be used when you 290 | /// have both a minimum and maximum value. 291 | /// [Optional] The name of the HTML attribute that 292 | /// contains the minimum value. The default is "min". 293 | /// [Optional] The name of the HTML attribute that 294 | /// contains the maximum value. The default is "max". 295 | /// 296 | return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { 297 | var min = options.params.min, 298 | max = options.params.max; 299 | 300 | if (min && max) { 301 | setValidationValues(options, minMaxRuleName, [min, max]); 302 | } 303 | else if (min) { 304 | setValidationValues(options, minRuleName, min); 305 | } 306 | else if (max) { 307 | setValidationValues(options, maxRuleName, max); 308 | } 309 | }); 310 | }; 311 | 312 | adapters.addSingleVal = function (adapterName, attribute, ruleName) { 313 | /// Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where 314 | /// the jQuery Validate validation rule has a single value. 315 | /// The name of the adapter to be added. This matches the name used 316 | /// in the data-val-nnnn HTML attribute(where nnnn is the adapter name). 317 | /// [Optional] The name of the HTML attribute that contains the value. 318 | /// The default is "val". 319 | /// [Optional] The name of the jQuery Validate rule. If not provided, the value 320 | /// of adapterName will be used instead. 321 | /// 322 | return this.add(adapterName, [attribute || "val"], function (options) { 323 | setValidationValues(options, ruleName || adapterName, options.params[attribute]); 324 | }); 325 | }; 326 | 327 | $jQval.addMethod("__dummy__", function (value, element, params) { 328 | return true; 329 | }); 330 | 331 | $jQval.addMethod("regex", function (value, element, params) { 332 | var match; 333 | if (this.optional(element)) { 334 | return true; 335 | } 336 | 337 | match = new RegExp(params).exec(value); 338 | return (match && (match.index === 0) && (match[0].length === value.length)); 339 | }); 340 | 341 | $jQval.addMethod("nonalphamin", function (value, element, nonalphamin) { 342 | var match; 343 | if (nonalphamin) { 344 | match = value.match(/\W/g); 345 | match = match && match.length >= nonalphamin; 346 | } 347 | return match; 348 | }); 349 | 350 | if ($jQval.methods.extension) { 351 | adapters.addSingleVal("accept", "mimtype"); 352 | adapters.addSingleVal("extension", "extension"); 353 | } else { 354 | // for backward compatibility, when the 'extension' validation method does not exist, such as with versions 355 | // of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for 356 | // validating the extension, and ignore mime-type validations as they are not supported. 357 | adapters.addSingleVal("extension", "extension", "accept"); 358 | } 359 | 360 | adapters.addSingleVal("regex", "pattern"); 361 | adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); 362 | adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); 363 | adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength"); 364 | adapters.add("equalto", ["other"], function (options) { 365 | var prefix = getModelPrefix(options.element.name), 366 | other = options.params.other, 367 | fullOtherName = appendModelPrefix(other, prefix), 368 | element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0]; 369 | 370 | setValidationValues(options, "equalTo", element); 371 | }); 372 | adapters.add("required", function (options) { 373 | // jQuery Validate equates "required" with "mandatory" for checkbox elements 374 | if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { 375 | setValidationValues(options, "required", true); 376 | } 377 | }); 378 | adapters.add("remote", ["url", "type", "additionalfields"], function (options) { 379 | var value = { 380 | url: options.params.url, 381 | type: options.params.type || "GET", 382 | data: {} 383 | }, 384 | prefix = getModelPrefix(options.element.name); 385 | 386 | $.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { 387 | var paramName = appendModelPrefix(fieldName, prefix); 388 | value.data[paramName] = function () { 389 | return $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']").val(); 390 | }; 391 | }); 392 | 393 | setValidationValues(options, "remote", value); 394 | }); 395 | adapters.add("password", ["min", "nonalphamin", "regex"], function (options) { 396 | if (options.params.min) { 397 | setValidationValues(options, "minlength", options.params.min); 398 | } 399 | if (options.params.nonalphamin) { 400 | setValidationValues(options, "nonalphamin", options.params.nonalphamin); 401 | } 402 | if (options.params.regex) { 403 | setValidationValues(options, "regex", options.params.regex); 404 | } 405 | }); 406 | 407 | $(function () { 408 | $jQval.unobtrusive.parse(document); 409 | }); 410 | }(jQuery)); -------------------------------------------------------------------------------- /A11_RBS/Scripts/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /* 16 | ** Unobtrusive validation support library for jQuery and jQuery Validate 17 | ** Copyright (C) Microsoft Corporation. All rights reserved. 18 | */ 19 | (function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("
  • ").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this);b.data("validator").resetForm();b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(b){var c=a(b),f=c.data(e),i=a.proxy(n,b),g=d.unobtrusive.options||{},h=function(e,d){var c=g[e];c&&a.isFunction(c)&&c.apply(b,d)};if(!f){f={options:{errorClass:g.errorClass||"input-validation-error",errorElement:g.errorElement||"span",errorPlacement:function(){m.apply(b,arguments);h("errorPlacement",arguments)},invalidHandler:function(){l.apply(b,arguments);h("invalidHandler",arguments)},messages:{},rules:{},success:function(){k.apply(b,arguments);h("success",arguments)}},attachValidation:function(){c.off("reset."+e,i).on("reset."+e,i).validate(this.options)},validate:function(){c.validate();return c.valid()}};c.data(e,f)}return f}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(c){var b=a(c),e=b.parents().addBack().filter("form").add(b.find("form")).has("[data-val=true]");b.find("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});e.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){return a(b.form).find(":input").filter("[name='"+f(c)+"']").val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery); -------------------------------------------------------------------------------- /A11_RBS/Scripts/respond.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia = window.matchMedia || (function(doc, undefined){ 18 | 19 | var bool, 20 | docElem = doc.documentElement, 21 | refNode = docElem.firstElementChild || docElem.firstChild, 22 | // fakeBody required for 23 | fakeBody = doc.createElement('body'), 24 | div = doc.createElement('div'); 25 | 26 | div.id = 'mq-test-1'; 27 | div.style.cssText = "position:absolute;top:-100em"; 28 | fakeBody.style.background = "none"; 29 | fakeBody.appendChild(div); 30 | 31 | return function(q){ 32 | 33 | div.innerHTML = '­'; 34 | 35 | docElem.insertBefore(fakeBody, refNode); 36 | bool = div.offsetWidth == 42; 37 | docElem.removeChild(fakeBody); 38 | 39 | return { matches: bool, media: q }; 40 | }; 41 | 42 | })(document); 43 | 44 | 45 | 46 | 47 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 48 | (function( win ){ 49 | //exposed namespace 50 | win.respond = {}; 51 | 52 | //define update even in native-mq-supporting browsers, to avoid errors 53 | respond.update = function(){}; 54 | 55 | //expose media query support flag for external use 56 | respond.mediaQueriesSupported = win.matchMedia && win.matchMedia( "only all" ).matches; 57 | 58 | //if media queries are supported, exit here 59 | if( respond.mediaQueriesSupported ){ return; } 60 | 61 | //define vars 62 | var doc = win.document, 63 | docElem = doc.documentElement, 64 | mediastyles = [], 65 | rules = [], 66 | appendedEls = [], 67 | parsedSheets = {}, 68 | resizeThrottle = 30, 69 | head = doc.getElementsByTagName( "head" )[0] || docElem, 70 | base = doc.getElementsByTagName( "base" )[0], 71 | links = head.getElementsByTagName( "link" ), 72 | requestQueue = [], 73 | 74 | //loop stylesheets, send text content to translate 75 | ripCSS = function(){ 76 | var sheets = links, 77 | sl = sheets.length, 78 | i = 0, 79 | //vars for loop: 80 | sheet, href, media, isCSS; 81 | 82 | for( ; i < sl; i++ ){ 83 | sheet = sheets[ i ], 84 | href = sheet.href, 85 | media = sheet.media, 86 | isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; 87 | 88 | //only links plz and prevent re-parsing 89 | if( !!href && isCSS && !parsedSheets[ href ] ){ 90 | // selectivizr exposes css through the rawCssText expando 91 | if (sheet.styleSheet && sheet.styleSheet.rawCssText) { 92 | translate( sheet.styleSheet.rawCssText, href, media ); 93 | parsedSheets[ href ] = true; 94 | } else { 95 | if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) 96 | || href.replace( RegExp.$1, "" ).split( "/" )[0] === win.location.host ){ 97 | requestQueue.push( { 98 | href: href, 99 | media: media 100 | } ); 101 | } 102 | } 103 | } 104 | } 105 | makeRequests(); 106 | }, 107 | 108 | //recurse through request queue, get css text 109 | makeRequests = function(){ 110 | if( requestQueue.length ){ 111 | var thisRequest = requestQueue.shift(); 112 | 113 | ajax( thisRequest.href, function( styles ){ 114 | translate( styles, thisRequest.href, thisRequest.media ); 115 | parsedSheets[ thisRequest.href ] = true; 116 | makeRequests(); 117 | } ); 118 | } 119 | }, 120 | 121 | //find media blocks in css text, convert to style blocks 122 | translate = function( styles, href, media ){ 123 | var qs = styles.match( /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi ), 124 | ql = qs && qs.length || 0, 125 | //try to get CSS path 126 | href = href.substring( 0, href.lastIndexOf( "/" )), 127 | repUrls = function( css ){ 128 | return css.replace( /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, "$1" + href + "$2$3" ); 129 | }, 130 | useMedia = !ql && media, 131 | //vars used in loop 132 | i = 0, 133 | j, fullq, thisq, eachq, eql; 134 | 135 | //if path exists, tack on trailing slash 136 | if( href.length ){ href += "/"; } 137 | 138 | //if no internal queries exist, but media attr does, use that 139 | //note: this currently lacks support for situations where a media attr is specified on a link AND 140 | //its associated stylesheet has internal CSS media queries. 141 | //In those cases, the media attribute will currently be ignored. 142 | if( useMedia ){ 143 | ql = 1; 144 | } 145 | 146 | 147 | for( ; i < ql; i++ ){ 148 | j = 0; 149 | 150 | //media attr 151 | if( useMedia ){ 152 | fullq = media; 153 | rules.push( repUrls( styles ) ); 154 | } 155 | //parse for styles 156 | else{ 157 | fullq = qs[ i ].match( /@media *([^\{]+)\{([\S\s]+?)$/ ) && RegExp.$1; 158 | rules.push( RegExp.$2 && repUrls( RegExp.$2 ) ); 159 | } 160 | 161 | eachq = fullq.split( "," ); 162 | eql = eachq.length; 163 | 164 | for( ; j < eql; j++ ){ 165 | thisq = eachq[ j ]; 166 | mediastyles.push( { 167 | media : thisq.split( "(" )[ 0 ].match( /(only\s+)?([a-zA-Z]+)\s?/ ) && RegExp.$2 || "all", 168 | rules : rules.length - 1, 169 | hasquery: thisq.indexOf("(") > -1, 170 | minw : thisq.match( /\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), 171 | maxw : thisq.match( /\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/ ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ) 172 | } ); 173 | } 174 | } 175 | 176 | applyMedia(); 177 | }, 178 | 179 | lastCall, 180 | 181 | resizeDefer, 182 | 183 | // returns the value of 1em in pixels 184 | getEmValue = function() { 185 | var ret, 186 | div = doc.createElement('div'), 187 | body = doc.body, 188 | fakeUsed = false; 189 | 190 | div.style.cssText = "position:absolute;font-size:1em;width:1em"; 191 | 192 | if( !body ){ 193 | body = fakeUsed = doc.createElement( "body" ); 194 | body.style.background = "none"; 195 | } 196 | 197 | body.appendChild( div ); 198 | 199 | docElem.insertBefore( body, docElem.firstChild ); 200 | 201 | ret = div.offsetWidth; 202 | 203 | if( fakeUsed ){ 204 | docElem.removeChild( body ); 205 | } 206 | else { 207 | body.removeChild( div ); 208 | } 209 | 210 | //also update eminpx before returning 211 | ret = eminpx = parseFloat(ret); 212 | 213 | return ret; 214 | }, 215 | 216 | //cached container for 1em value, populated the first time it's needed 217 | eminpx, 218 | 219 | //enable/disable styles 220 | applyMedia = function( fromResize ){ 221 | var name = "clientWidth", 222 | docElemProp = docElem[ name ], 223 | currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp, 224 | styleBlocks = {}, 225 | lastLink = links[ links.length-1 ], 226 | now = (new Date()).getTime(); 227 | 228 | //throttle resize calls 229 | if( fromResize && lastCall && now - lastCall < resizeThrottle ){ 230 | clearTimeout( resizeDefer ); 231 | resizeDefer = setTimeout( applyMedia, resizeThrottle ); 232 | return; 233 | } 234 | else { 235 | lastCall = now; 236 | } 237 | 238 | for( var i in mediastyles ){ 239 | var thisstyle = mediastyles[ i ], 240 | min = thisstyle.minw, 241 | max = thisstyle.maxw, 242 | minnull = min === null, 243 | maxnull = max === null, 244 | em = "em"; 245 | 246 | if( !!min ){ 247 | min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 248 | } 249 | if( !!max ){ 250 | max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); 251 | } 252 | 253 | // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true 254 | if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){ 255 | if( !styleBlocks[ thisstyle.media ] ){ 256 | styleBlocks[ thisstyle.media ] = []; 257 | } 258 | styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] ); 259 | } 260 | } 261 | 262 | //remove any existing respond style element(s) 263 | for( var i in appendedEls ){ 264 | if( appendedEls[ i ] && appendedEls[ i ].parentNode === head ){ 265 | head.removeChild( appendedEls[ i ] ); 266 | } 267 | } 268 | 269 | //inject active styles, grouped by media type 270 | for( var i in styleBlocks ){ 271 | var ss = doc.createElement( "style" ), 272 | css = styleBlocks[ i ].join( "\n" ); 273 | 274 | ss.type = "text/css"; 275 | ss.media = i; 276 | 277 | //originally, ss was appended to a documentFragment and sheets were appended in bulk. 278 | //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one! 279 | head.insertBefore( ss, lastLink.nextSibling ); 280 | 281 | if ( ss.styleSheet ){ 282 | ss.styleSheet.cssText = css; 283 | } 284 | else { 285 | ss.appendChild( doc.createTextNode( css ) ); 286 | } 287 | 288 | //push to appendedEls to track for later removal 289 | appendedEls.push( ss ); 290 | } 291 | }, 292 | //tweaked Ajax functions from Quirksmode 293 | ajax = function( url, callback ) { 294 | var req = xmlHttp(); 295 | if (!req){ 296 | return; 297 | } 298 | req.open( "GET", url, true ); 299 | req.onreadystatechange = function () { 300 | if ( req.readyState != 4 || req.status != 200 && req.status != 304 ){ 301 | return; 302 | } 303 | callback( req.responseText ); 304 | } 305 | if ( req.readyState == 4 ){ 306 | return; 307 | } 308 | req.send( null ); 309 | }, 310 | //define ajax obj 311 | xmlHttp = (function() { 312 | var xmlhttpmethod = false; 313 | try { 314 | xmlhttpmethod = new XMLHttpRequest(); 315 | } 316 | catch( e ){ 317 | xmlhttpmethod = new ActiveXObject( "Microsoft.XMLHTTP" ); 318 | } 319 | return function(){ 320 | return xmlhttpmethod; 321 | }; 322 | })(); 323 | 324 | //translate CSS 325 | ripCSS(); 326 | 327 | //expose update for re-running respond later on 328 | respond.update = ripCSS; 329 | 330 | //adjust on resize 331 | function callMedia(){ 332 | applyMedia( true ); 333 | } 334 | if( win.addEventListener ){ 335 | win.addEventListener( "resize", callMedia, false ); 336 | } 337 | else if( win.attachEvent ){ 338 | win.attachEvent( "onresize", callMedia ); 339 | } 340 | })(this); 341 | -------------------------------------------------------------------------------- /A11_RBS/Scripts/respond.min.js: -------------------------------------------------------------------------------- 1 | /* NUGET: BEGIN LICENSE TEXT 2 | * 3 | * Microsoft grants you the right to use these script files for the sole 4 | * purpose of either: (i) interacting through your browser with the Microsoft 5 | * website or online service, subject to the applicable licensing or use 6 | * terms; or (ii) using the files as included with a Microsoft product subject 7 | * to that product's license terms. Microsoft reserves all other rights to the 8 | * files not expressly granted by Microsoft, whether by implication, estoppel 9 | * or otherwise. Insofar as a script file is dual licensed under GPL, 10 | * Microsoft neither took the code under GPL nor distributes it thereunder but 11 | * under the terms set out in this paragraph. All notices and licenses 12 | * below are for informational purposes only. 13 | * 14 | * NUGET: END LICENSE TEXT */ 15 | /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */ 16 | /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */ 17 | window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='­';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document); 18 | 19 | /*! Respond.js v1.2.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */ 20 | (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this); -------------------------------------------------------------------------------- /A11_RBS/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Owin; 2 | using Owin; 3 | 4 | [assembly: OwinStartupAttribute(typeof(A11_RBS.Startup))] 5 | namespace A11_RBS 6 | { 7 | public partial class Startup 8 | { 9 | public void Configuration(IAppBuilder app) 10 | { 11 | ConfigureAuth(app); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ConfirmEmail.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Confirm Email"; 3 | } 4 | 5 |

    @ViewBag.Title.

    6 |
    7 |

    8 | Thank you for confirming your email. Please @Html.ActionLink("Click here to Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) 9 |

    10 |
    11 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ExternalLoginConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ExternalLoginConfirmationViewModel 2 | @{ 3 | ViewBag.Title = "Register"; 4 | } 5 |

    @ViewBag.Title.

    6 |

    Associate your @ViewBag.LoginProvider account.

    7 | 8 | @using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 | 12 |

    Association Form

    13 |
    14 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 15 |

    16 | You've successfully authenticated with @ViewBag.LoginProvider. 17 | Please enter a user name for this site below and click the Register button to finish 18 | logging in. 19 |

    20 |
    21 | @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) 22 |
    23 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 24 | @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" }) 25 |
    26 |
    27 |
    28 |
    29 | 30 |
    31 |
    32 | } 33 | 34 | @section Scripts { 35 | @Scripts.Render("~/bundles/jqueryval") 36 | } 37 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ExternalLoginFailure.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Login Failure"; 3 | } 4 | 5 |
    6 |

    @ViewBag.Title.

    7 |

    Unsuccessful login with service.

    8 |
    9 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ForgotPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ForgotPasswordViewModel 2 | @{ 3 | ViewBag.Title = "Forgot your password?"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("ForgotPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

    Enter your email.

    12 |
    13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 |
    15 | @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) 16 |
    17 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 18 |
    19 |
    20 |
    21 |
    22 | 23 |
    24 |
    25 | } 26 | 27 | @section Scripts { 28 | @Scripts.Render("~/bundles/jqueryval") 29 | } 30 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ForgotPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Forgot Password Confirmation"; 3 | } 4 | 5 |
    6 |

    @ViewBag.Title.

    7 |
    8 |
    9 |

    10 | Please check your email to reset your password. 11 |

    12 |
    13 | 14 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 | @using A11_RBS.Models 2 | @model LoginViewModel 3 | @{ 4 | ViewBag.Title = "Log in"; 5 | } 6 | 7 |

    @ViewBag.Title.

    8 |
    9 |
    10 |
    11 | @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 12 | { 13 | @Html.AntiForgeryToken() 14 |

    Use a local account to log in.

    15 |
    16 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 17 |
    18 | @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) 19 |
    20 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 21 | @Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" }) 22 |
    23 |
    24 |
    25 | @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) 26 |
    27 | @Html.PasswordFor(m => m.Password, new { @class = "form-control" }) 28 | @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" }) 29 |
    30 |
    31 |
    32 |
    33 |
    34 | @Html.CheckBoxFor(m => m.RememberMe) 35 | @Html.LabelFor(m => m.RememberMe) 36 |
    37 |
    38 |
    39 |
    40 |
    41 | 42 |
    43 |
    44 |

    45 | @Html.ActionLink("Register as a new user", "Register") 46 |

    47 | @* Enable this once you have account confirmation enabled for password reset functionality 48 |

    49 | @Html.ActionLink("Forgot your password?", "ForgotPassword") 50 |

    *@ 51 | } 52 |
    53 |
    54 |
    55 |
    56 | @Html.Partial("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl }) 57 |
    58 |
    59 |
    60 | 61 | @section Scripts { 62 | @Scripts.Render("~/bundles/jqueryval") 63 | } -------------------------------------------------------------------------------- /A11_RBS/Views/Account/Register.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.RegisterViewModel 2 | @{ 3 | ViewBag.Title = "Register"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

    Create a new account.

    12 |
    13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 |
    15 | @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) 16 |
    17 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 18 |
    19 |
    20 |
    21 | @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) 22 |
    23 | @Html.PasswordFor(m => m.Password, new { @class = "form-control" }) 24 |
    25 |
    26 |
    27 | @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) 28 |
    29 | @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) 30 |
    31 |
    32 | 33 |
    34 | @Html.Label("Select Your User Type", new { @class = "col-md-2 control-label" }) 35 |
    36 | @Html.DropDownList("Name") 37 |
    38 |
    39 | 40 | 41 |
    42 |
    43 | 44 |
    45 |
    46 | } 47 | 48 | @section Scripts { 49 | @Scripts.Render("~/bundles/jqueryval") 50 | } 51 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ResetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ResetPasswordViewModel 2 | @{ 3 | ViewBag.Title = "Reset password"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("ResetPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

    Reset your password.

    12 |
    13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 | @Html.HiddenFor(model => model.Code) 15 |
    16 | @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) 17 |
    18 | @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) 19 |
    20 |
    21 |
    22 | @Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" }) 23 |
    24 | @Html.PasswordFor(m => m.Password, new { @class = "form-control" }) 25 |
    26 |
    27 |
    28 | @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) 29 |
    30 | @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) 31 |
    32 |
    33 |
    34 |
    35 | 36 |
    37 |
    38 | } 39 | 40 | @section Scripts { 41 | @Scripts.Render("~/bundles/jqueryval") 42 | } 43 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/ResetPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Reset password confirmation"; 3 | } 4 | 5 |
    6 |

    @ViewBag.Title.

    7 |
    8 |
    9 |

    10 | Your password has been reset. Please @Html.ActionLink("click here to log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" }) 11 |

    12 |
    13 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/SendCode.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.SendCodeViewModel 2 | @{ 3 | ViewBag.Title = "Send"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("SendCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) { 9 | @Html.AntiForgeryToken() 10 | @Html.Hidden("rememberMe", @Model.RememberMe) 11 |

    Send verification code

    12 |
    13 |
    14 |
    15 | Select Two-Factor Authentication Provider: 16 | @Html.DropDownListFor(model => model.SelectedProvider, Model.Providers) 17 | 18 |
    19 |
    20 | } 21 | 22 | @section Scripts { 23 | @Scripts.Render("~/bundles/jqueryval") 24 | } 25 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/VerifyCode.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.VerifyCodeViewModel 2 | @{ 3 | ViewBag.Title = "Verify"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("VerifyCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" })) { 9 | @Html.AntiForgeryToken() 10 | @Html.Hidden("provider", @Model.Provider) 11 | @Html.Hidden("rememberMe", @Model.RememberMe) 12 |

    Enter verification code

    13 |
    14 | @Html.ValidationSummary("", new { @class = "text-danger" }) 15 |
    16 | @Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" }) 17 |
    18 | @Html.TextBoxFor(m => m.Code, new { @class = "form-control" }) 19 |
    20 |
    21 |
    22 |
    23 |
    24 | @Html.CheckBoxFor(m => m.RememberBrowser) 25 | @Html.LabelFor(m => m.RememberBrowser) 26 |
    27 |
    28 |
    29 |
    30 |
    31 | 32 |
    33 |
    34 | } 35 | 36 | @section Scripts { 37 | @Scripts.Render("~/bundles/jqueryval") 38 | } 39 | -------------------------------------------------------------------------------- /A11_RBS/Views/Account/_ExternalLoginsListPartial.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ExternalLoginListViewModel 2 | @using Microsoft.Owin.Security 3 | 4 |

    Use another service to log in.

    5 |
    6 | @{ 7 | var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes(); 8 | if (loginProviders.Count() == 0) { 9 |
    10 |

    11 | There are no external authentication services configured. See this article 12 | for details on setting up this ASP.NET application to support logging in via external services. 13 |

    14 |
    15 | } 16 | else { 17 | using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl })) { 18 | @Html.AntiForgeryToken() 19 |
    20 |

    21 | @foreach (AuthenticationDescription p in loginProviders) { 22 | 23 | } 24 |

    25 |
    26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /A11_RBS/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "About"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |

    Use this area to provide additional information.

    8 | -------------------------------------------------------------------------------- /A11_RBS/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Contact"; 3 | } 4 |

    @ViewBag.Title.

    5 |

    @ViewBag.Message

    6 | 7 |
    8 | One Microsoft Way
    9 | Redmond, WA 98052-6399
    10 | P: 11 | 425.555.0100 12 |
    13 | 14 |
    15 | Support: Support@example.com
    16 | Marketing: Marketing@example.com 17 |
    -------------------------------------------------------------------------------- /A11_RBS/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewBag.Title = "Home Page"; 3 | } 4 | 5 |
    6 |

    ASP.NET

    7 |

    ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

    8 |

    Learn more »

    9 |
    10 | 11 |
    12 |
    13 |

    Getting started

    14 |

    15 | ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that 16 | enables a clean separation of concerns and gives you full control over markup 17 | for enjoyable, agile development. 18 |

    19 |

    Learn more »

    20 |
    21 |
    22 |

    Get more libraries

    23 |

    NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.

    24 |

    Learn more »

    25 |
    26 |
    27 |

    Web Hosting

    28 |

    You can easily find a web hosting company that offers the right mix of features and price for your applications.

    29 |

    Learn more »

    30 |
    31 |
    -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/AddPhoneNumber.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.AddPhoneNumberViewModel 2 | @{ 3 | ViewBag.Title = "Phone Number"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("AddPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

    Add a phone number

    12 |
    13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 |
    15 | @Html.LabelFor(m => m.Number, new { @class = "col-md-2 control-label" }) 16 |
    17 | @Html.TextBoxFor(m => m.Number, new { @class = "form-control" }) 18 |
    19 |
    20 |
    21 |
    22 | 23 |
    24 |
    25 | } 26 | 27 | @section Scripts { 28 | @Scripts.Render("~/bundles/jqueryval") 29 | } 30 | -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/ChangePassword.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ChangePasswordViewModel 2 | @{ 3 | ViewBag.Title = "Change Password"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("ChangePassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 |

    Change Password Form

    12 |
    13 | @Html.ValidationSummary("", new { @class = "text-danger" }) 14 |
    15 | @Html.LabelFor(m => m.OldPassword, new { @class = "col-md-2 control-label" }) 16 |
    17 | @Html.PasswordFor(m => m.OldPassword, new { @class = "form-control" }) 18 |
    19 |
    20 |
    21 | @Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) 22 |
    23 | @Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) 24 |
    25 |
    26 |
    27 | @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) 28 |
    29 | @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) 30 |
    31 |
    32 |
    33 |
    34 | 35 |
    36 |
    37 | } 38 | @section Scripts { 39 | @Scripts.Render("~/bundles/jqueryval") 40 | } -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.IndexViewModel 2 | @{ 3 | ViewBag.Title = "Manage"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 |

    @ViewBag.StatusMessage

    9 |
    10 |

    Change your account settings

    11 |
    12 |
    13 |
    Password:
    14 |
    15 | [ 16 | @if (Model.HasPassword) 17 | { 18 | @Html.ActionLink("Change your password", "ChangePassword") 19 | } 20 | else 21 | { 22 | @Html.ActionLink("Create", "SetPassword") 23 | } 24 | ] 25 |
    26 |
    External Logins:
    27 |
    28 | @Model.Logins.Count [ 29 | @Html.ActionLink("Manage", "ManageLogins") ] 30 |
    31 | @* 32 | Phone Numbers can used as a second factor of verification in a two-factor authentication system. 33 | 34 | See this article 35 | for details on setting up this ASP.NET application to support two-factor authentication using SMS. 36 | 37 | Uncomment the following block after you have set up two-factor authentication 38 | *@ 39 | @* 40 |
    Phone Number:
    41 |
    42 | @(Model.PhoneNumber ?? "None") [ 43 | @if (Model.PhoneNumber != null) 44 | { 45 | @Html.ActionLink("Change", "AddPhoneNumber") 46 | @:  |  47 | @Html.ActionLink("Remove", "RemovePhoneNumber") 48 | } 49 | else 50 | { 51 | @Html.ActionLink("Add", "AddPhoneNumber") 52 | } 53 | ] 54 |
    55 | *@ 56 |
    Two-Factor Authentication:
    57 |
    58 |

    59 | There are no two-factor authentication providers configured. See this article 60 | for details on setting up this ASP.NET application to support two-factor authentication. 61 |

    62 | @*@if (Model.TwoFactor) 63 | { 64 | using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 65 | { 66 | @Html.AntiForgeryToken() 67 | Enabled 68 | 69 | 70 | } 71 | } 72 | else 73 | { 74 | using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 75 | { 76 | @Html.AntiForgeryToken() 77 | Disabled 78 | 79 | 80 | } 81 | }*@ 82 |
    83 |
    84 |
    85 | -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/ManageLogins.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ManageLoginsViewModel 2 | @using Microsoft.Owin.Security 3 | @{ 4 | ViewBag.Title = "Manage your external logins"; 5 | } 6 | 7 |

    @ViewBag.Title.

    8 | 9 |

    @ViewBag.StatusMessage

    10 | @{ 11 | var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes(); 12 | if (loginProviders.Count() == 0) { 13 |
    14 |

    15 | There are no external authentication services configured. See this article 16 | for details on setting up this ASP.NET application to support logging in via external services. 17 |

    18 |
    19 | } 20 | else 21 | { 22 | if (Model.CurrentLogins.Count > 0) 23 | { 24 |

    Registered Logins

    25 | 26 | 27 | @foreach (var account in Model.CurrentLogins) 28 | { 29 | 30 | 31 | 49 | 50 | } 51 | 52 |
    @account.LoginProvider 32 | @if (ViewBag.ShowRemoveButton) 33 | { 34 | using (Html.BeginForm("RemoveLogin", "Manage")) 35 | { 36 | @Html.AntiForgeryToken() 37 |
    38 | @Html.Hidden("loginProvider", account.LoginProvider) 39 | @Html.Hidden("providerKey", account.ProviderKey) 40 | 41 |
    42 | } 43 | } 44 | else 45 | { 46 | @:   47 | } 48 |
    53 | } 54 | if (Model.OtherLogins.Count > 0) 55 | { 56 | using (Html.BeginForm("LinkLogin", "Manage")) 57 | { 58 | @Html.AntiForgeryToken() 59 |
    60 |

    61 | @foreach (AuthenticationDescription p in Model.OtherLogins) 62 | { 63 | 64 | } 65 |

    66 |
    67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/SetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.SetPasswordViewModel 2 | @{ 3 | ViewBag.Title = "Create Password"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 |

    8 | You do not have a local username/password for this site. Add a local 9 | account so you can log in without an external login. 10 |

    11 | 12 | @using (Html.BeginForm("SetPassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 13 | { 14 | @Html.AntiForgeryToken() 15 | 16 |

    Create Local Login

    17 |
    18 | @Html.ValidationSummary("", new { @class = "text-danger" }) 19 |
    20 | @Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" }) 21 |
    22 | @Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" }) 23 |
    24 |
    25 |
    26 | @Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" }) 27 |
    28 | @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" }) 29 |
    30 |
    31 |
    32 |
    33 | 34 |
    35 |
    36 | } 37 | @section Scripts { 38 | @Scripts.Render("~/bundles/jqueryval") 39 | } -------------------------------------------------------------------------------- /A11_RBS/Views/Manage/VerifyPhoneNumber.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.VerifyPhoneNumberViewModel 2 | @{ 3 | ViewBag.Title = "Verify Phone Number"; 4 | } 5 | 6 |

    @ViewBag.Title.

    7 | 8 | @using (Html.BeginForm("VerifyPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" })) 9 | { 10 | @Html.AntiForgeryToken() 11 | @Html.Hidden("phoneNumber", @Model.PhoneNumber) 12 |

    Enter verification code

    13 |
    @ViewBag.Status
    14 |
    15 | @Html.ValidationSummary("", new { @class = "text-danger" }) 16 |
    17 | @Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" }) 18 |
    19 | @Html.TextBoxFor(m => m.Code, new { @class = "form-control" }) 20 |
    21 |
    22 |
    23 |
    24 | 25 |
    26 |
    27 | } 28 | 29 | @section Scripts { 30 | @Scripts.Render("~/bundles/jqueryval") 31 | } 32 | -------------------------------------------------------------------------------- /A11_RBS/Views/Product/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model A11_RBS.Models.ProductMaster 2 | 3 | @{ 4 | ViewBag.Title = "Create"; 5 | } 6 | 7 |

    Create

    8 | 9 | @using (Html.BeginForm()) 10 | { 11 | @Html.AntiForgeryToken() 12 | 13 |
    14 |

    ProductMaster

    15 |
    16 | @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 17 |
    18 | @Html.LabelFor(model => model.ProductName, htmlAttributes: new { @class = "control-label col-md-2" }) 19 |
    20 | @Html.EditorFor(model => model.ProductName, new { htmlAttributes = new { @class = "form-control" } }) 21 | @Html.ValidationMessageFor(model => model.ProductName, "", new { @class = "text-danger" }) 22 |
    23 |
    24 | 25 |
    26 | @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" }) 27 |
    28 | @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } }) 29 | @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" }) 30 |
    31 |
    32 | 33 |
    34 |
    35 | 36 |
    37 |
    38 |
    39 | } 40 | 41 |
    42 | @Html.ActionLink("Back to List", "Index") 43 |
    44 | -------------------------------------------------------------------------------- /A11_RBS/Views/Product/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewBag.Title = "Index"; 5 | } 6 | 7 |

    Index

    8 | 9 |

    10 | @Html.ActionLink("Create New", "Create") 11 |

    12 | 13 | 14 | 17 | 20 | 23 | 24 | 25 | 26 | @foreach (var item in Model) { 27 | 28 | 31 | 34 | 37 | 38 | } 39 | 40 |
    15 | @Html.DisplayNameFor(model => model.ProductId) 16 | 18 | @Html.DisplayNameFor(model => model.ProductName) 19 | 21 | @Html.DisplayNameFor(model => model.Price) 22 |
    29 | @Html.DisplayFor(modelItem => item.ProductId) 30 | 32 | @Html.DisplayFor(modelItem => item.ProductName) 33 | 35 | @Html.DisplayFor(modelItem => item.Price) 36 |
    41 | -------------------------------------------------------------------------------- /A11_RBS/Views/Product/SaleProduct.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewBag.Title = "SaleProduct"; 4 | } 5 | 6 |

    Sale Product

    7 | @ViewBag.Message 8 | -------------------------------------------------------------------------------- /A11_RBS/Views/Role/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model Microsoft.AspNet.Identity.EntityFramework.IdentityRole 2 | @{ 3 | ViewBag.Title = "Create"; 4 | } 5 | 6 |

    Create

    7 | 8 | 13 | 14 | 15 | @using (Html.BeginForm()) 16 | { 17 | 18 | 19 | 20 | 23 | 24 |
    Enter Role Name To be Created: 21 | @Html.EditorFor(m => m.Name) 22 |
    25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /A11_RBS/Views/Role/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | @{ 3 | ViewBag.Title = "Index"; 4 | } 5 | 6 |

    Available Roles For Application

    7 | 8 | @Html.ActionLink("Create Role","Create","Role") 9 | 10 | 15 | 16 | 17 | 18 | 21 | 22 | @foreach (var item in Model) 23 | { 24 | 25 | 28 | 29 | } 30 |
    19 | Role Name 20 |
    26 | @item.Name 27 |
    31 | 32 | -------------------------------------------------------------------------------- /A11_RBS/Views/Role/SetRoleToUser.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewBag.Title = "SetRoleToUser"; 4 | } 5 | 6 |

    Set Role for User

    7 | 8 | 9 | 10 | 13 | 16 | 17 |
    11 | @Html.ActionLink("Create Role", "Create") 12 | 14 | @Html.ActionLink("Set Role To User", "SetRoleToUser") 15 |
    18 | 19 | 20 |

    Role Add to User

    21 | @using (Html.BeginForm("SetRoleToUser", "Role")) 22 | { 23 | @Html.AntiForgeryToken() 24 | @Html.ValidationSummary(true) 25 | 26 |

    27 | Username : @Html.Editor("UserName") 28 | Role Name: @Html.DropDownList("RoleName", ( 29 | IEnumerable)ViewBag.Roles, "Select Role") 30 |

    31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /A11_RBS/Views/Shared/AuthorizeFailed.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | @{ 4 | ViewBag.Title = "AuthorizeFailed"; 5 | } 6 | 7 |

    Authorize Failed

    8 | 9 | @ViewData["Message"] 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /A11_RBS/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Web.Mvc.HandleErrorInfo 2 | 3 | @{ 4 | ViewBag.Title = "Error"; 5 | } 6 | 7 |

    Error.

    8 |

    An error occurred while processing your request.

    9 | 10 | -------------------------------------------------------------------------------- /A11_RBS/Views/Shared/Lockout.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Web.Mvc.HandleErrorInfo 2 | 3 | @{ 4 | ViewBag.Title = "Locked Out"; 5 | } 6 | 7 |
    8 |

    Locked out.

    9 |

    This account has been locked out, please try again later.

    10 |
    11 | -------------------------------------------------------------------------------- /A11_RBS/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewBag.Title - My ASP.NET Application 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 | 12 | 37 |
    38 | @RenderBody() 39 |
    40 |
    41 |

    © @DateTime.Now.Year - My ASP.NET Application

    42 |
    43 |
    44 | 45 | @Scripts.Render("~/bundles/jquery") 46 | @Scripts.Render("~/bundles/bootstrap") 47 | @RenderSection("scripts", required: false) 48 | 49 | 50 | -------------------------------------------------------------------------------- /A11_RBS/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNet.Identity 2 | @if (Request.IsAuthenticated) 3 | { 4 | using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" })) 5 | { 6 | @Html.AntiForgeryToken() 7 | 8 | 14 | } 15 | } 16 | else 17 | { 18 | 22 | } 23 | -------------------------------------------------------------------------------- /A11_RBS/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
    7 |
    8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /A11_RBS/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /A11_RBS/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /A11_RBS/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /A11_RBS/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 |
    10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /A11_RBS/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/favicon.ico -------------------------------------------------------------------------------- /A11_RBS/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /A11_RBS/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /A11_RBS/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/A11_RBS.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\A11_RBS.dll.config 2 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\A11_RBS.dll 3 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\A11_RBS.pdb 4 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Antlr3.Runtime.dll 5 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\EntityFramework.dll 6 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\EntityFramework.SqlServer.dll 7 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.Core.dll 8 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.EntityFramework.dll 9 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.Owin.dll 10 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.dll 11 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Host.SystemWeb.dll 12 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Cookies.dll 13 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.dll 14 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Facebook.dll 15 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Google.dll 16 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.MicrosoftAccount.dll 17 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.OAuth.dll 18 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Twitter.dll 19 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Web.Infrastructure.dll 20 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Newtonsoft.Json.dll 21 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Owin.dll 22 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Helpers.dll 23 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Mvc.dll 24 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Optimization.dll 25 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Razor.dll 26 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.Deployment.dll 27 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.dll 28 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.Razor.dll 29 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\WebGrease.dll 30 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Helpers.xml 31 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Mvc.xml 32 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Optimization.xml 33 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.Razor.xml 34 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.xml 35 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.Deployment.xml 36 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\System.Web.WebPages.Razor.xml 37 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Antlr3.Runtime.pdb 38 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Newtonsoft.Json.xml 39 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\EntityFramework.xml 40 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\EntityFramework.SqlServer.xml 41 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.Core.xml 42 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.Owin.xml 43 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.AspNet.Identity.EntityFramework.xml 44 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.xml 45 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Host.SystemWeb.xml 46 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.xml 47 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Facebook.xml 48 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Cookies.xml 49 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.OAuth.xml 50 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Google.xml 51 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.Twitter.xml 52 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\bin\Microsoft.Owin.Security.MicrosoftAccount.xml 53 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\obj\Debug\A11_RBS.csprojResolveAssemblyReference.cache 54 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\obj\Debug\A11_RBS.dll 55 | F:\Mahesh_New\Articles\Jan15\A11_RBS\A11_RBS\obj\Debug\A11_RBS.pdb 56 | -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/A11_RBS.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/A11_RBS.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/A11_RBS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/A11_RBS.dll -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/A11_RBS.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/A11_RBS.pdb -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/TempPE/Models.SuperMarketEDMX.Designer.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/TempPE/Models.SuperMarketEDMX.Designer.cs.dll -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/TempPE/Models.SuperMarketEDMX.cs.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/TempPE/Models.SuperMarketEDMX.cs.dll -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dotnetcurry/role-security-mvc5/c02b92d6c93e94d5eddab8628163bdc750e0cacb/A11_RBS/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/edmxResourcesToEmbed/Models/SuperMarketEDMX.csdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/edmxResourcesToEmbed/Models/SuperMarketEDMX.msl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /A11_RBS/obj/Debug/edmxResourcesToEmbed/Models/SuperMarketEDMX.ssdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /A11_RBS/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /prd.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE [dbo].[ProductMaster] 2 | ( 3 | [ProductId] INT identity PRIMARY KEY, 4 | [ProductName] VARCHAR(50) NOT NULL, 5 | [Price] VARCHAR(50) NOT NULL 6 | ) 7 | --------------------------------------------------------------------------------