├── .gitignore ├── LICENSE ├── README.md ├── coderush.sln └── coderush ├── Areas └── Membership │ ├── Controllers │ └── HomeController.cs │ ├── ViewModels │ ├── ChangeUserPasswordViewModel.cs │ └── RegisterUserViewModel.cs │ └── Views │ ├── Home │ ├── ChangePassword.cshtml │ ├── Create.cshtml │ ├── Delete.cshtml │ ├── Details.cshtml │ ├── Edit.cshtml │ └── Index.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── Controllers ├── AccountController.cs ├── HomeController.cs └── ManageController.cs ├── Data └── ApplicationDbContext.cs ├── Extensions ├── EmailSenderExtensions.cs └── UrlHelperExtensions.cs ├── Migrations ├── 20180723040435_identity.Designer.cs ├── 20180723040435_identity.cs └── ApplicationDbContextModelSnapshot.cs ├── Models ├── AccountViewModels │ ├── ExternalLoginViewModel.cs │ ├── ForgotPasswordViewModel.cs │ ├── LoginViewModel.cs │ ├── LoginWith2faViewModel.cs │ ├── LoginWithRecoveryCodeViewModel.cs │ ├── RegisterViewModel.cs │ └── ResetPasswordViewModel.cs ├── ApplicationUser.cs ├── ErrorViewModel.cs └── ManageViewModels │ ├── ChangePasswordViewModel.cs │ ├── EnableAuthenticatorViewModel.cs │ ├── ExternalLoginsViewModel.cs │ ├── IndexViewModel.cs │ ├── RemoveLoginViewModel.cs │ ├── SetPasswordViewModel.cs │ ├── ShowRecoveryCodesViewModel.cs │ └── TwoFactorAuthenticationViewModel.cs ├── Program.cs ├── ScaffoldingReadMe.txt ├── Services ├── EmailSender.cs └── IEmailSender.cs ├── Startup.cs ├── Views ├── Account │ ├── AccessDenied.cshtml │ ├── ConfirmEmail.cshtml │ ├── ExternalLogin.cshtml │ ├── ForgotPassword.cshtml │ ├── ForgotPasswordConfirmation.cshtml │ ├── Lockout.cshtml │ ├── Login.cshtml │ ├── LoginWith2fa.cshtml │ ├── LoginWithRecoveryCode.cshtml │ ├── Register.cshtml │ ├── ResetPassword.cshtml │ ├── ResetPasswordConfirmation.cshtml │ └── SignedOut.cshtml ├── Home │ ├── About.cshtml │ ├── Contact.cshtml │ └── Index.cshtml ├── Manage │ ├── ChangePassword.cshtml │ ├── Disable2fa.cshtml │ ├── EnableAuthenticator.cshtml │ ├── ExternalLogins.cshtml │ ├── GenerateRecoveryCodes.cshtml │ ├── Index.cshtml │ ├── ManageNavPages.cs │ ├── ResetAuthenticator.cshtml │ ├── SetPassword.cshtml │ ├── ShowRecoveryCodes.cshtml │ ├── TwoFactorAuthentication.cshtml │ ├── _Layout.cshtml │ ├── _ManageNav.cshtml │ ├── _StatusMessage.cshtml │ └── _ViewImports.cshtml ├── Shared │ ├── Error.cshtml │ ├── _Layout.cshtml │ ├── _LoginPartial.cshtml │ └── _ValidationScriptsPartial.cshtml ├── _ViewImports.cshtml └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json ├── bundleconfig.json ├── coderush.csproj └── wwwroot ├── css ├── site.css └── site.min.css ├── favicon.ico ├── images ├── banner1.svg ├── banner2.svg ├── banner3.svg ├── banner4.svg └── membership.png ├── js ├── site.js └── site.min.js └── lib ├── bootstrap ├── .bower.json ├── LICENSE └── dist │ ├── css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.css.map │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap.css │ ├── bootstrap.css.map │ ├── bootstrap.min.css │ └── bootstrap.min.css.map │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ └── js │ ├── bootstrap.js │ ├── bootstrap.min.js │ └── npm.js ├── jquery-validation-unobtrusive ├── .bower.json ├── jquery.validate.unobtrusive.js └── jquery.validate.unobtrusive.min.js ├── jquery-validation ├── .bower.json ├── LICENSE.md └── dist │ ├── additional-methods.js │ ├── additional-methods.min.js │ ├── jquery.validate.js │ └── jquery.validate.min.js └── jquery ├── .bower.json ├── LICENSE.txt └── dist ├── jquery.js ├── jquery.min.js └── jquery.min.map /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 go2ismail 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Asp.Net-Core-Membership-Simple-Example 2 | Simple example implementation of membership using Asp.Net Core Mvc that will allow you to Create, Retrieve, Update and Delete application users. 3 | 4 | # Screenshots 5 | 6 | ![membership](coderush/wwwroot/images/membership.png) 7 | 8 | # Supported by CodeRush.Co 9 | [CodeRush.CO] source code collections (https://coderush.co). 50% Off All Products, Use Discount Code **GITHUB50** 10 | -------------------------------------------------------------------------------- /coderush.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2042 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "coderush", "coderush\coderush.csproj", "{963285B3-8245-47D9-8395-142DE185463B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {963285B3-8245-47D9-8395-142DE185463B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {963285B3-8245-47D9-8395-142DE185463B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {963285B3-8245-47D9-8395-142DE185463B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {963285B3-8245-47D9-8395-142DE185463B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {2154CB5C-F7DD-493D-9948-F3A1FE0F7382} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using coderush.Areas.Membership.ViewModels; 6 | using coderush.Data; 7 | using coderush.Models; 8 | using Microsoft.AspNetCore.Authorization; 9 | using Microsoft.AspNetCore.Identity; 10 | using Microsoft.AspNetCore.Mvc; 11 | 12 | namespace coderush.Areas.Membership.Controllers 13 | { 14 | [Area("Membership")] 15 | [Authorize] 16 | public class HomeController : Controller 17 | { 18 | private readonly ApplicationDbContext _context; 19 | private readonly UserManager _userManager; 20 | private readonly SignInManager _signInManager; 21 | 22 | public HomeController(ApplicationDbContext context, 23 | UserManager userManager, 24 | SignInManager signInManager) 25 | { 26 | _context = context; 27 | _userManager = userManager; 28 | _signInManager = signInManager; 29 | } 30 | 31 | public IActionResult Index() 32 | { 33 | return View(_context.Users.ToList()); 34 | } 35 | 36 | // GET: Membership/Home/Create 37 | public IActionResult Create() 38 | { 39 | return View(); 40 | } 41 | 42 | // POST: Membership/Home/Create 43 | [HttpPost] 44 | [ValidateAntiForgeryToken] 45 | public async Task Create([Bind("Email,Password,ConfirmPassword")] RegisterUserViewModel model) 46 | { 47 | if (ModelState.IsValid) 48 | { 49 | var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 50 | var result = await _userManager.CreateAsync(user, model.Password); 51 | if (result.Succeeded) 52 | { 53 | 54 | var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); 55 | return RedirectToAction(nameof(Index)); 56 | 57 | } 58 | 59 | AddErrors(result); 60 | 61 | } 62 | 63 | return View(model); 64 | } 65 | 66 | // GET: Membership/Home/Edit/xxx 67 | public async Task Edit(string id) 68 | { 69 | if (id == null) 70 | { 71 | return NotFound(); 72 | } 73 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 74 | 75 | if (appUser == null) 76 | { 77 | return NotFound(); 78 | } 79 | return View(appUser); 80 | } 81 | 82 | // POST: Membership/Home/Edit/xxx 83 | [HttpPost] 84 | [ValidateAntiForgeryToken] 85 | public async Task Edit(string id, [Bind("Id,Email")] ApplicationUser model) 86 | { 87 | if (id != model.Id) 88 | { 89 | return NotFound(); 90 | } 91 | 92 | if (ModelState.IsValid) 93 | { 94 | try 95 | { 96 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 97 | if (appUser != null) 98 | { 99 | var email = appUser.Email; 100 | if (model.Email != email) 101 | { 102 | var setEmailResult = await _userManager.SetEmailAsync(appUser, model.Email); 103 | return RedirectToAction(nameof(Index)); 104 | } 105 | } 106 | } 107 | catch (Exception) 108 | { 109 | 110 | throw; 111 | } 112 | 113 | } 114 | return View(model); 115 | } 116 | 117 | // GET: Membership/Home/Details/xxx 118 | public async Task Details(string id) 119 | { 120 | if (id == null) 121 | { 122 | return NotFound(); 123 | } 124 | 125 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 126 | 127 | if (appUser == null) 128 | { 129 | return NotFound(); 130 | } 131 | 132 | return View(appUser); 133 | } 134 | 135 | // GET: Membership/Home/Delete/xxx 136 | public async Task Delete(string id) 137 | { 138 | if (id == null) 139 | { 140 | return NotFound(); 141 | } 142 | 143 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 144 | 145 | if (appUser == null) 146 | { 147 | return NotFound(); 148 | } 149 | 150 | return View(appUser); 151 | } 152 | 153 | // POST: Membership/Home/Delete/xxx 154 | [HttpPost, ActionName("Delete")] 155 | [ValidateAntiForgeryToken] 156 | public async Task DeleteConfirmed(string id) 157 | { 158 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 159 | var result = await _userManager.DeleteAsync(appUser); 160 | 161 | return RedirectToAction(nameof(Index)); 162 | } 163 | 164 | // GET: Membership/Home/ChangePassword/xxx 165 | public async Task ChangePassword(string id) 166 | { 167 | if (id == null) 168 | { 169 | return NotFound(); 170 | } 171 | 172 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 173 | 174 | if (appUser == null) 175 | { 176 | return NotFound(); 177 | } 178 | 179 | ChangeUserPasswordViewModel changePassword = new ChangeUserPasswordViewModel(); 180 | changePassword.Id = appUser.Id; 181 | changePassword.Email = appUser.Email; 182 | 183 | return View(changePassword); 184 | } 185 | 186 | // POST: Membership/Home/ChangePassword/xxx 187 | [HttpPost] 188 | [ValidateAntiForgeryToken] 189 | public async Task ChangePassword(string id, [Bind("Id,Email,OldPassword,NewPassword,ConfirmPassword")] ChangeUserPasswordViewModel model) 190 | { 191 | if (id != model.Id) 192 | { 193 | return NotFound(); 194 | } 195 | 196 | if (ModelState.IsValid) 197 | { 198 | try 199 | { 200 | ApplicationUser appUser = await _userManager.FindByIdAsync(id); 201 | if (appUser != null) 202 | { 203 | var changePasswordResult = await _userManager.ChangePasswordAsync(appUser, model.OldPassword, model.NewPassword); 204 | if (!changePasswordResult.Succeeded) 205 | { 206 | AddErrors(changePasswordResult); 207 | ChangeUserPasswordViewModel changePassword = new ChangeUserPasswordViewModel(); 208 | changePassword.Id = appUser.Id; 209 | changePassword.Email = appUser.Email; 210 | return View(changePassword); 211 | } 212 | 213 | return RedirectToAction(nameof(Index)); 214 | } 215 | } 216 | catch (Exception) 217 | { 218 | 219 | throw; 220 | } 221 | 222 | } 223 | return View(model); 224 | } 225 | 226 | private void AddErrors(IdentityResult result) 227 | { 228 | foreach (var error in result.Errors) 229 | { 230 | ModelState.AddModelError(string.Empty, error.Description); 231 | } 232 | } 233 | } 234 | } -------------------------------------------------------------------------------- /coderush/Areas/Membership/ViewModels/ChangeUserPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Areas.Membership.ViewModels 8 | { 9 | public class ChangeUserPasswordViewModel 10 | { 11 | 12 | public string Id { get; set; } 13 | public string Email { get; set; } 14 | 15 | [Required] 16 | [DataType(DataType.Password)] 17 | [Display(Name = "Current password")] 18 | public string OldPassword { get; set; } 19 | 20 | [Required] 21 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 22 | [DataType(DataType.Password)] 23 | [Display(Name = "New password")] 24 | public string NewPassword { get; set; } 25 | 26 | [DataType(DataType.Password)] 27 | [Display(Name = "Confirm new password")] 28 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 29 | public string ConfirmPassword { get; set; } 30 | 31 | public string StatusMessage { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/ViewModels/RegisterUserViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Areas.Membership.ViewModels 8 | { 9 | public class RegisterUserViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | [Display(Name = "Email")] 14 | public string Email { get; set; } 15 | 16 | [Required] 17 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "Password")] 20 | public string Password { get; set; } 21 | 22 | [DataType(DataType.Password)] 23 | [Display(Name = "Confirm password")] 24 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 25 | public string ConfirmPassword { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/ChangePassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ChangeUserPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Change password"; 4 | } 5 | 6 |

@ViewData["Title"]

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 | Back to List 41 |
42 | 43 | @section Scripts { 44 | @await Html.PartialAsync("_ValidationScriptsPartial") 45 | } 46 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model RegisterUserViewModel 2 | @{ 3 | ViewData["Title"] = "Register"; 4 | } 5 | 6 |

@ViewData["Title"]

7 | 8 |
9 |
10 |
11 |

Create a new account.

12 |
13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 | 30 |
31 |
32 |
33 | 34 |
35 | Back to List 36 |
37 | 38 | @section Scripts { 39 | @await Html.PartialAsync("_ValidationScriptsPartial") 40 | } 41 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model ApplicationUser 2 | 3 | @{ 4 | ViewData["Title"] = "Delete"; 5 | } 6 | 7 |

Delete

8 | 9 |

Are you sure you want to delete this?

10 |
11 |

Application User

12 |
13 |
14 |
15 | @Html.DisplayNameFor(model => model.Id) 16 |
17 |
18 | @Html.DisplayFor(model => model.Id) 19 |
20 |
21 | @Html.DisplayNameFor(model => model.UserName) 22 |
23 |
24 | @Html.DisplayFor(model => model.UserName) 25 |
26 |
27 | @Html.DisplayNameFor(model => model.Email) 28 |
29 |
30 | @Html.DisplayFor(model => model.Email) 31 |
32 |
33 | 34 |
35 | 36 | | 37 | Back to List 38 |
39 |
40 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model ApplicationUser 2 | 3 | @{ 4 | ViewData["Title"] = "Details"; 5 | } 6 | 7 |

Details

8 | 9 |
10 |

Application User Details

11 |
12 |
13 |
14 | @Html.DisplayNameFor(model => model.UserName) 15 |
16 |
17 | @Html.DisplayFor(model => model.UserName) 18 |
19 |
20 | @Html.DisplayNameFor(model => model.Email) 21 |
22 |
23 | @Html.DisplayFor(model => model.Email) 24 |
25 |
26 |
27 |
28 | Edit | 29 | Back to List 30 |
31 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model ApplicationUser 2 | @{ 3 | ViewData["Title"] = "Edit"; 4 | } 5 | 6 |

@ViewData["Title"]

7 | 8 |
9 |
10 |
11 |

Application User.

12 |
13 |
14 | 15 |
16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | Back to List 32 |
33 | 34 | @section Scripts { 35 | @await Html.PartialAsync("_ValidationScriptsPartial") 36 | } 37 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "Index"; 5 | } 6 | 7 |

Index

8 | 9 |

10 | Create New 11 |

12 | 13 | 14 | 15 | 18 | 21 | 24 | 25 | 26 | 27 | 28 | @foreach (var item in Model) 29 | { 30 | 31 | 34 | 37 | 40 | 46 | 47 | } 48 | 49 |
16 | @Html.DisplayNameFor(model => model.Id) 17 | 19 | @Html.DisplayNameFor(model => model.UserName) 20 | 22 | @Html.DisplayNameFor(model => model.Email) 23 |
32 | @Html.DisplayFor(modelItem => item.Id) 33 | 35 | @Html.DisplayFor(modelItem => item.UserName) 36 | 38 | @Html.DisplayFor(modelItem => item.Email) 39 | 41 | Edit | 42 | Change Password | 43 | Details | 44 | Delete 45 |
50 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using coderush 3 | @using coderush.Models 4 | @using coderush.Models.AccountViewModels 5 | @using coderush.Models.ManageViewModels 6 | @using coderush.Areas.Membership.ViewModels 7 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 8 | -------------------------------------------------------------------------------- /coderush/Areas/Membership/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /coderush/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Claims; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Authentication; 7 | using Microsoft.AspNetCore.Authorization; 8 | using Microsoft.AspNetCore.Identity; 9 | using Microsoft.AspNetCore.Mvc; 10 | using Microsoft.AspNetCore.Mvc.Rendering; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.Extensions.Options; 13 | using coderush.Models; 14 | using coderush.Models.AccountViewModels; 15 | using coderush.Services; 16 | 17 | namespace coderush.Controllers 18 | { 19 | [Authorize] 20 | [Route("[controller]/[action]")] 21 | public class AccountController : Controller 22 | { 23 | private readonly UserManager _userManager; 24 | private readonly SignInManager _signInManager; 25 | private readonly IEmailSender _emailSender; 26 | private readonly ILogger _logger; 27 | 28 | public AccountController( 29 | UserManager userManager, 30 | SignInManager signInManager, 31 | IEmailSender emailSender, 32 | ILogger logger) 33 | { 34 | _userManager = userManager; 35 | _signInManager = signInManager; 36 | _emailSender = emailSender; 37 | _logger = logger; 38 | } 39 | 40 | [TempData] 41 | public string ErrorMessage { get; set; } 42 | 43 | [HttpGet] 44 | [AllowAnonymous] 45 | public async Task Login(string returnUrl = null) 46 | { 47 | // Clear the existing external cookie to ensure a clean login process 48 | await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); 49 | 50 | ViewData["ReturnUrl"] = returnUrl; 51 | return View(); 52 | } 53 | 54 | [HttpPost] 55 | [AllowAnonymous] 56 | [ValidateAntiForgeryToken] 57 | public async Task Login(LoginViewModel model, string returnUrl = null) 58 | { 59 | ViewData["ReturnUrl"] = returnUrl; 60 | if (ModelState.IsValid) 61 | { 62 | // This doesn't count login failures towards account lockout 63 | // To enable password failures to trigger account lockout, set lockoutOnFailure: true 64 | var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false); 65 | if (result.Succeeded) 66 | { 67 | _logger.LogInformation("User logged in."); 68 | return RedirectToLocal(returnUrl); 69 | } 70 | if (result.RequiresTwoFactor) 71 | { 72 | return RedirectToAction(nameof(LoginWith2fa), new { returnUrl, model.RememberMe }); 73 | } 74 | if (result.IsLockedOut) 75 | { 76 | _logger.LogWarning("User account locked out."); 77 | return RedirectToAction(nameof(Lockout)); 78 | } 79 | else 80 | { 81 | ModelState.AddModelError(string.Empty, "Invalid login attempt."); 82 | return View(model); 83 | } 84 | } 85 | 86 | // If we got this far, something failed, redisplay form 87 | return View(model); 88 | } 89 | 90 | [HttpGet] 91 | [AllowAnonymous] 92 | public async Task LoginWith2fa(bool rememberMe, string returnUrl = null) 93 | { 94 | // Ensure the user has gone through the username & password screen first 95 | var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); 96 | 97 | if (user == null) 98 | { 99 | throw new ApplicationException($"Unable to load two-factor authentication user."); 100 | } 101 | 102 | var model = new LoginWith2faViewModel { RememberMe = rememberMe }; 103 | ViewData["ReturnUrl"] = returnUrl; 104 | 105 | return View(model); 106 | } 107 | 108 | [HttpPost] 109 | [AllowAnonymous] 110 | [ValidateAntiForgeryToken] 111 | public async Task LoginWith2fa(LoginWith2faViewModel model, bool rememberMe, string returnUrl = null) 112 | { 113 | if (!ModelState.IsValid) 114 | { 115 | return View(model); 116 | } 117 | 118 | var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); 119 | if (user == null) 120 | { 121 | throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); 122 | } 123 | 124 | var authenticatorCode = model.TwoFactorCode.Replace(" ", string.Empty).Replace("-", string.Empty); 125 | 126 | var result = await _signInManager.TwoFactorAuthenticatorSignInAsync(authenticatorCode, rememberMe, model.RememberMachine); 127 | 128 | if (result.Succeeded) 129 | { 130 | _logger.LogInformation("User with ID {UserId} logged in with 2fa.", user.Id); 131 | return RedirectToLocal(returnUrl); 132 | } 133 | else if (result.IsLockedOut) 134 | { 135 | _logger.LogWarning("User with ID {UserId} account locked out.", user.Id); 136 | return RedirectToAction(nameof(Lockout)); 137 | } 138 | else 139 | { 140 | _logger.LogWarning("Invalid authenticator code entered for user with ID {UserId}.", user.Id); 141 | ModelState.AddModelError(string.Empty, "Invalid authenticator code."); 142 | return View(); 143 | } 144 | } 145 | 146 | [HttpGet] 147 | [AllowAnonymous] 148 | public async Task LoginWithRecoveryCode(string returnUrl = null) 149 | { 150 | // Ensure the user has gone through the username & password screen first 151 | var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); 152 | if (user == null) 153 | { 154 | throw new ApplicationException($"Unable to load two-factor authentication user."); 155 | } 156 | 157 | ViewData["ReturnUrl"] = returnUrl; 158 | 159 | return View(); 160 | } 161 | 162 | [HttpPost] 163 | [AllowAnonymous] 164 | [ValidateAntiForgeryToken] 165 | public async Task LoginWithRecoveryCode(LoginWithRecoveryCodeViewModel model, string returnUrl = null) 166 | { 167 | if (!ModelState.IsValid) 168 | { 169 | return View(model); 170 | } 171 | 172 | var user = await _signInManager.GetTwoFactorAuthenticationUserAsync(); 173 | if (user == null) 174 | { 175 | throw new ApplicationException($"Unable to load two-factor authentication user."); 176 | } 177 | 178 | var recoveryCode = model.RecoveryCode.Replace(" ", string.Empty); 179 | 180 | var result = await _signInManager.TwoFactorRecoveryCodeSignInAsync(recoveryCode); 181 | 182 | if (result.Succeeded) 183 | { 184 | _logger.LogInformation("User with ID {UserId} logged in with a recovery code.", user.Id); 185 | return RedirectToLocal(returnUrl); 186 | } 187 | if (result.IsLockedOut) 188 | { 189 | _logger.LogWarning("User with ID {UserId} account locked out.", user.Id); 190 | return RedirectToAction(nameof(Lockout)); 191 | } 192 | else 193 | { 194 | _logger.LogWarning("Invalid recovery code entered for user with ID {UserId}", user.Id); 195 | ModelState.AddModelError(string.Empty, "Invalid recovery code entered."); 196 | return View(); 197 | } 198 | } 199 | 200 | [HttpGet] 201 | [AllowAnonymous] 202 | public IActionResult Lockout() 203 | { 204 | return View(); 205 | } 206 | 207 | [HttpGet] 208 | [AllowAnonymous] 209 | public IActionResult Register(string returnUrl = null) 210 | { 211 | ViewData["ReturnUrl"] = returnUrl; 212 | return View(); 213 | } 214 | 215 | [HttpPost] 216 | [AllowAnonymous] 217 | [ValidateAntiForgeryToken] 218 | public async Task Register(RegisterViewModel model, string returnUrl = null) 219 | { 220 | ViewData["ReturnUrl"] = returnUrl; 221 | if (ModelState.IsValid) 222 | { 223 | var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 224 | var result = await _userManager.CreateAsync(user, model.Password); 225 | if (result.Succeeded) 226 | { 227 | _logger.LogInformation("User created a new account with password."); 228 | 229 | var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); 230 | var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); 231 | await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); 232 | 233 | await _signInManager.SignInAsync(user, isPersistent: false); 234 | _logger.LogInformation("User created a new account with password."); 235 | return RedirectToLocal(returnUrl); 236 | } 237 | AddErrors(result); 238 | } 239 | 240 | // If we got this far, something failed, redisplay form 241 | return View(model); 242 | } 243 | 244 | [HttpPost] 245 | [ValidateAntiForgeryToken] 246 | public async Task Logout() 247 | { 248 | await _signInManager.SignOutAsync(); 249 | _logger.LogInformation("User logged out."); 250 | return RedirectToAction(nameof(HomeController.Index), "Home"); 251 | } 252 | 253 | [HttpPost] 254 | [AllowAnonymous] 255 | [ValidateAntiForgeryToken] 256 | public IActionResult ExternalLogin(string provider, string returnUrl = null) 257 | { 258 | // Request a redirect to the external login provider. 259 | var redirectUrl = Url.Action(nameof(ExternalLoginCallback), "Account", new { returnUrl }); 260 | var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); 261 | return Challenge(properties, provider); 262 | } 263 | 264 | [HttpGet] 265 | [AllowAnonymous] 266 | public async Task ExternalLoginCallback(string returnUrl = null, string remoteError = null) 267 | { 268 | if (remoteError != null) 269 | { 270 | ErrorMessage = $"Error from external provider: {remoteError}"; 271 | return RedirectToAction(nameof(Login)); 272 | } 273 | var info = await _signInManager.GetExternalLoginInfoAsync(); 274 | if (info == null) 275 | { 276 | return RedirectToAction(nameof(Login)); 277 | } 278 | 279 | // Sign in the user with this external login provider if the user already has a login. 280 | var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor: true); 281 | if (result.Succeeded) 282 | { 283 | _logger.LogInformation("User logged in with {Name} provider.", info.LoginProvider); 284 | return RedirectToLocal(returnUrl); 285 | } 286 | if (result.IsLockedOut) 287 | { 288 | return RedirectToAction(nameof(Lockout)); 289 | } 290 | else 291 | { 292 | // If the user does not have an account, then ask the user to create an account. 293 | ViewData["ReturnUrl"] = returnUrl; 294 | ViewData["LoginProvider"] = info.LoginProvider; 295 | var email = info.Principal.FindFirstValue(ClaimTypes.Email); 296 | return View("ExternalLogin", new ExternalLoginViewModel { Email = email }); 297 | } 298 | } 299 | 300 | [HttpPost] 301 | [AllowAnonymous] 302 | [ValidateAntiForgeryToken] 303 | public async Task ExternalLoginConfirmation(ExternalLoginViewModel model, string returnUrl = null) 304 | { 305 | if (ModelState.IsValid) 306 | { 307 | // Get the information about the user from the external login provider 308 | var info = await _signInManager.GetExternalLoginInfoAsync(); 309 | if (info == null) 310 | { 311 | throw new ApplicationException("Error loading external login information during confirmation."); 312 | } 313 | var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; 314 | var result = await _userManager.CreateAsync(user); 315 | if (result.Succeeded) 316 | { 317 | result = await _userManager.AddLoginAsync(user, info); 318 | if (result.Succeeded) 319 | { 320 | await _signInManager.SignInAsync(user, isPersistent: false); 321 | _logger.LogInformation("User created an account using {Name} provider.", info.LoginProvider); 322 | return RedirectToLocal(returnUrl); 323 | } 324 | } 325 | AddErrors(result); 326 | } 327 | 328 | ViewData["ReturnUrl"] = returnUrl; 329 | return View(nameof(ExternalLogin), model); 330 | } 331 | 332 | [HttpGet] 333 | [AllowAnonymous] 334 | public async Task ConfirmEmail(string userId, string code) 335 | { 336 | if (userId == null || code == null) 337 | { 338 | return RedirectToAction(nameof(HomeController.Index), "Home"); 339 | } 340 | var user = await _userManager.FindByIdAsync(userId); 341 | if (user == null) 342 | { 343 | throw new ApplicationException($"Unable to load user with ID '{userId}'."); 344 | } 345 | var result = await _userManager.ConfirmEmailAsync(user, code); 346 | return View(result.Succeeded ? "ConfirmEmail" : "Error"); 347 | } 348 | 349 | [HttpGet] 350 | [AllowAnonymous] 351 | public IActionResult ForgotPassword() 352 | { 353 | return View(); 354 | } 355 | 356 | [HttpPost] 357 | [AllowAnonymous] 358 | [ValidateAntiForgeryToken] 359 | public async Task ForgotPassword(ForgotPasswordViewModel model) 360 | { 361 | if (ModelState.IsValid) 362 | { 363 | var user = await _userManager.FindByEmailAsync(model.Email); 364 | if (user == null || !(await _userManager.IsEmailConfirmedAsync(user))) 365 | { 366 | // Don't reveal that the user does not exist or is not confirmed 367 | return RedirectToAction(nameof(ForgotPasswordConfirmation)); 368 | } 369 | 370 | // For more information on how to enable account confirmation and password reset please 371 | // visit https://go.microsoft.com/fwlink/?LinkID=532713 372 | var code = await _userManager.GeneratePasswordResetTokenAsync(user); 373 | var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme); 374 | await _emailSender.SendEmailAsync(model.Email, "Reset Password", 375 | $"Please reset your password by clicking here: link"); 376 | return RedirectToAction(nameof(ForgotPasswordConfirmation)); 377 | } 378 | 379 | // If we got this far, something failed, redisplay form 380 | return View(model); 381 | } 382 | 383 | [HttpGet] 384 | [AllowAnonymous] 385 | public IActionResult ForgotPasswordConfirmation() 386 | { 387 | return View(); 388 | } 389 | 390 | [HttpGet] 391 | [AllowAnonymous] 392 | public IActionResult ResetPassword(string code = null) 393 | { 394 | if (code == null) 395 | { 396 | throw new ApplicationException("A code must be supplied for password reset."); 397 | } 398 | var model = new ResetPasswordViewModel { Code = code }; 399 | return View(model); 400 | } 401 | 402 | [HttpPost] 403 | [AllowAnonymous] 404 | [ValidateAntiForgeryToken] 405 | public async Task ResetPassword(ResetPasswordViewModel model) 406 | { 407 | if (!ModelState.IsValid) 408 | { 409 | return View(model); 410 | } 411 | var user = await _userManager.FindByEmailAsync(model.Email); 412 | if (user == null) 413 | { 414 | // Don't reveal that the user does not exist 415 | return RedirectToAction(nameof(ResetPasswordConfirmation)); 416 | } 417 | var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password); 418 | if (result.Succeeded) 419 | { 420 | return RedirectToAction(nameof(ResetPasswordConfirmation)); 421 | } 422 | AddErrors(result); 423 | return View(); 424 | } 425 | 426 | [HttpGet] 427 | [AllowAnonymous] 428 | public IActionResult ResetPasswordConfirmation() 429 | { 430 | return View(); 431 | } 432 | 433 | 434 | [HttpGet] 435 | public IActionResult AccessDenied() 436 | { 437 | return View(); 438 | } 439 | 440 | #region Helpers 441 | 442 | private void AddErrors(IdentityResult result) 443 | { 444 | foreach (var error in result.Errors) 445 | { 446 | ModelState.AddModelError(string.Empty, error.Description); 447 | } 448 | } 449 | 450 | private IActionResult RedirectToLocal(string returnUrl) 451 | { 452 | if (Url.IsLocalUrl(returnUrl)) 453 | { 454 | return Redirect(returnUrl); 455 | } 456 | else 457 | { 458 | return RedirectToAction(nameof(HomeController.Index), "Home"); 459 | } 460 | } 461 | 462 | #endregion 463 | } 464 | } 465 | -------------------------------------------------------------------------------- /coderush/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using coderush.Models; 8 | 9 | namespace coderush.Controllers 10 | { 11 | public class HomeController : Controller 12 | { 13 | public IActionResult Index() 14 | { 15 | return View(); 16 | } 17 | 18 | public IActionResult About() 19 | { 20 | ViewData["Message"] = "Your application description page."; 21 | 22 | return View(); 23 | } 24 | 25 | public IActionResult Contact() 26 | { 27 | ViewData["Message"] = "Your contact page."; 28 | 29 | return View(); 30 | } 31 | 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /coderush/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 6 | using Microsoft.EntityFrameworkCore; 7 | using coderush.Models; 8 | 9 | namespace coderush.Data 10 | { 11 | public class ApplicationDbContext : IdentityDbContext 12 | { 13 | public ApplicationDbContext(DbContextOptions options) 14 | : base(options) 15 | { 16 | } 17 | 18 | protected override void OnModelCreating(ModelBuilder builder) 19 | { 20 | base.OnModelCreating(builder); 21 | // Customize the ASP.NET Identity model and override the defaults if needed. 22 | // For example, you can rename the ASP.NET Identity table names and more. 23 | // Add your customizations after calling base.OnModelCreating(builder); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coderush/Extensions/EmailSenderExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text.Encodings.Web; 5 | using System.Threading.Tasks; 6 | using coderush.Services; 7 | 8 | namespace coderush.Services 9 | { 10 | public static class EmailSenderExtensions 11 | { 12 | public static Task SendEmailConfirmationAsync(this IEmailSender emailSender, string email, string link) 13 | { 14 | return emailSender.SendEmailAsync(email, "Confirm your email", 15 | $"Please confirm your account by clicking this link: link"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /coderush/Extensions/UrlHelperExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using coderush.Controllers; 6 | 7 | namespace Microsoft.AspNetCore.Mvc 8 | { 9 | public static class UrlHelperExtensions 10 | { 11 | public static string EmailConfirmationLink(this IUrlHelper urlHelper, string userId, string code, string scheme) 12 | { 13 | return urlHelper.Action( 14 | action: nameof(AccountController.ConfirmEmail), 15 | controller: "Account", 16 | values: new { userId, code }, 17 | protocol: scheme); 18 | } 19 | 20 | public static string ResetPasswordCallbackLink(this IUrlHelper urlHelper, string userId, string code, string scheme) 21 | { 22 | return urlHelper.Action( 23 | action: nameof(AccountController.ResetPassword), 24 | controller: "Account", 25 | values: new { userId, code }, 26 | protocol: scheme); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /coderush/Migrations/20180723040435_identity.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using coderush.Data; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage; 8 | using Microsoft.EntityFrameworkCore.Storage.Internal; 9 | using System; 10 | 11 | namespace coderush.Migrations 12 | { 13 | [DbContext(typeof(ApplicationDbContext))] 14 | [Migration("20180723040435_identity")] 15 | partial class identity 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("ProductVersion", "2.0.3-rtm-10026") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("coderush.Models.ApplicationUser", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd(); 28 | 29 | b.Property("AccessFailedCount"); 30 | 31 | b.Property("ConcurrencyStamp") 32 | .IsConcurrencyToken(); 33 | 34 | b.Property("Email") 35 | .HasMaxLength(256); 36 | 37 | b.Property("EmailConfirmed"); 38 | 39 | b.Property("LockoutEnabled"); 40 | 41 | b.Property("LockoutEnd"); 42 | 43 | b.Property("NormalizedEmail") 44 | .HasMaxLength(256); 45 | 46 | b.Property("NormalizedUserName") 47 | .HasMaxLength(256); 48 | 49 | b.Property("PasswordHash"); 50 | 51 | b.Property("PhoneNumber"); 52 | 53 | b.Property("PhoneNumberConfirmed"); 54 | 55 | b.Property("SecurityStamp"); 56 | 57 | b.Property("TwoFactorEnabled"); 58 | 59 | b.Property("UserName") 60 | .HasMaxLength(256); 61 | 62 | b.HasKey("Id"); 63 | 64 | b.HasIndex("NormalizedEmail") 65 | .HasName("EmailIndex"); 66 | 67 | b.HasIndex("NormalizedUserName") 68 | .IsUnique() 69 | .HasName("UserNameIndex") 70 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 71 | 72 | b.ToTable("AspNetUsers"); 73 | }); 74 | 75 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 76 | { 77 | b.Property("Id") 78 | .ValueGeneratedOnAdd(); 79 | 80 | b.Property("ConcurrencyStamp") 81 | .IsConcurrencyToken(); 82 | 83 | b.Property("Name") 84 | .HasMaxLength(256); 85 | 86 | b.Property("NormalizedName") 87 | .HasMaxLength(256); 88 | 89 | b.HasKey("Id"); 90 | 91 | b.HasIndex("NormalizedName") 92 | .IsUnique() 93 | .HasName("RoleNameIndex") 94 | .HasFilter("[NormalizedName] IS NOT NULL"); 95 | 96 | b.ToTable("AspNetRoles"); 97 | }); 98 | 99 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 100 | { 101 | b.Property("Id") 102 | .ValueGeneratedOnAdd(); 103 | 104 | b.Property("ClaimType"); 105 | 106 | b.Property("ClaimValue"); 107 | 108 | b.Property("RoleId") 109 | .IsRequired(); 110 | 111 | b.HasKey("Id"); 112 | 113 | b.HasIndex("RoleId"); 114 | 115 | b.ToTable("AspNetRoleClaims"); 116 | }); 117 | 118 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 119 | { 120 | b.Property("Id") 121 | .ValueGeneratedOnAdd(); 122 | 123 | b.Property("ClaimType"); 124 | 125 | b.Property("ClaimValue"); 126 | 127 | b.Property("UserId") 128 | .IsRequired(); 129 | 130 | b.HasKey("Id"); 131 | 132 | b.HasIndex("UserId"); 133 | 134 | b.ToTable("AspNetUserClaims"); 135 | }); 136 | 137 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 138 | { 139 | b.Property("LoginProvider"); 140 | 141 | b.Property("ProviderKey"); 142 | 143 | b.Property("ProviderDisplayName"); 144 | 145 | b.Property("UserId") 146 | .IsRequired(); 147 | 148 | b.HasKey("LoginProvider", "ProviderKey"); 149 | 150 | b.HasIndex("UserId"); 151 | 152 | b.ToTable("AspNetUserLogins"); 153 | }); 154 | 155 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 156 | { 157 | b.Property("UserId"); 158 | 159 | b.Property("RoleId"); 160 | 161 | b.HasKey("UserId", "RoleId"); 162 | 163 | b.HasIndex("RoleId"); 164 | 165 | b.ToTable("AspNetUserRoles"); 166 | }); 167 | 168 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 169 | { 170 | b.Property("UserId"); 171 | 172 | b.Property("LoginProvider"); 173 | 174 | b.Property("Name"); 175 | 176 | b.Property("Value"); 177 | 178 | b.HasKey("UserId", "LoginProvider", "Name"); 179 | 180 | b.ToTable("AspNetUserTokens"); 181 | }); 182 | 183 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 184 | { 185 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") 186 | .WithMany() 187 | .HasForeignKey("RoleId") 188 | .OnDelete(DeleteBehavior.Cascade); 189 | }); 190 | 191 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 192 | { 193 | b.HasOne("coderush.Models.ApplicationUser") 194 | .WithMany() 195 | .HasForeignKey("UserId") 196 | .OnDelete(DeleteBehavior.Cascade); 197 | }); 198 | 199 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 200 | { 201 | b.HasOne("coderush.Models.ApplicationUser") 202 | .WithMany() 203 | .HasForeignKey("UserId") 204 | .OnDelete(DeleteBehavior.Cascade); 205 | }); 206 | 207 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 208 | { 209 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") 210 | .WithMany() 211 | .HasForeignKey("RoleId") 212 | .OnDelete(DeleteBehavior.Cascade); 213 | 214 | b.HasOne("coderush.Models.ApplicationUser") 215 | .WithMany() 216 | .HasForeignKey("UserId") 217 | .OnDelete(DeleteBehavior.Cascade); 218 | }); 219 | 220 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 221 | { 222 | b.HasOne("coderush.Models.ApplicationUser") 223 | .WithMany() 224 | .HasForeignKey("UserId") 225 | .OnDelete(DeleteBehavior.Cascade); 226 | }); 227 | #pragma warning restore 612, 618 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /coderush/Migrations/20180723040435_identity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Metadata; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace coderush.Migrations 7 | { 8 | public partial class identity : Migration 9 | { 10 | protected override void Up(MigrationBuilder migrationBuilder) 11 | { 12 | migrationBuilder.CreateTable( 13 | name: "AspNetRoles", 14 | columns: table => new 15 | { 16 | Id = table.Column(nullable: false), 17 | ConcurrencyStamp = table.Column(nullable: true), 18 | Name = table.Column(maxLength: 256, nullable: true), 19 | NormalizedName = table.Column(maxLength: 256, nullable: true) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_AspNetRoles", x => x.Id); 24 | }); 25 | 26 | migrationBuilder.CreateTable( 27 | name: "AspNetUsers", 28 | columns: table => new 29 | { 30 | Id = table.Column(nullable: false), 31 | AccessFailedCount = table.Column(nullable: false), 32 | ConcurrencyStamp = table.Column(nullable: true), 33 | Email = table.Column(maxLength: 256, nullable: true), 34 | EmailConfirmed = table.Column(nullable: false), 35 | LockoutEnabled = table.Column(nullable: false), 36 | LockoutEnd = table.Column(nullable: true), 37 | NormalizedEmail = table.Column(maxLength: 256, nullable: true), 38 | NormalizedUserName = table.Column(maxLength: 256, nullable: true), 39 | PasswordHash = table.Column(nullable: true), 40 | PhoneNumber = table.Column(nullable: true), 41 | PhoneNumberConfirmed = table.Column(nullable: false), 42 | SecurityStamp = table.Column(nullable: true), 43 | TwoFactorEnabled = table.Column(nullable: false), 44 | UserName = table.Column(maxLength: 256, nullable: true) 45 | }, 46 | constraints: table => 47 | { 48 | table.PrimaryKey("PK_AspNetUsers", x => x.Id); 49 | }); 50 | 51 | migrationBuilder.CreateTable( 52 | name: "AspNetRoleClaims", 53 | columns: table => new 54 | { 55 | Id = table.Column(nullable: false) 56 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 57 | ClaimType = table.Column(nullable: true), 58 | ClaimValue = table.Column(nullable: true), 59 | RoleId = table.Column(nullable: false) 60 | }, 61 | constraints: table => 62 | { 63 | table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); 64 | table.ForeignKey( 65 | name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", 66 | column: x => x.RoleId, 67 | principalTable: "AspNetRoles", 68 | principalColumn: "Id", 69 | onDelete: ReferentialAction.Cascade); 70 | }); 71 | 72 | migrationBuilder.CreateTable( 73 | name: "AspNetUserClaims", 74 | columns: table => new 75 | { 76 | Id = table.Column(nullable: false) 77 | .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), 78 | ClaimType = table.Column(nullable: true), 79 | ClaimValue = table.Column(nullable: true), 80 | UserId = table.Column(nullable: false) 81 | }, 82 | constraints: table => 83 | { 84 | table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); 85 | table.ForeignKey( 86 | name: "FK_AspNetUserClaims_AspNetUsers_UserId", 87 | column: x => x.UserId, 88 | principalTable: "AspNetUsers", 89 | principalColumn: "Id", 90 | onDelete: ReferentialAction.Cascade); 91 | }); 92 | 93 | migrationBuilder.CreateTable( 94 | name: "AspNetUserLogins", 95 | columns: table => new 96 | { 97 | LoginProvider = table.Column(nullable: false), 98 | ProviderKey = table.Column(nullable: false), 99 | ProviderDisplayName = table.Column(nullable: true), 100 | UserId = table.Column(nullable: false) 101 | }, 102 | constraints: table => 103 | { 104 | table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); 105 | table.ForeignKey( 106 | name: "FK_AspNetUserLogins_AspNetUsers_UserId", 107 | column: x => x.UserId, 108 | principalTable: "AspNetUsers", 109 | principalColumn: "Id", 110 | onDelete: ReferentialAction.Cascade); 111 | }); 112 | 113 | migrationBuilder.CreateTable( 114 | name: "AspNetUserRoles", 115 | columns: table => new 116 | { 117 | UserId = table.Column(nullable: false), 118 | RoleId = table.Column(nullable: false) 119 | }, 120 | constraints: table => 121 | { 122 | table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); 123 | table.ForeignKey( 124 | name: "FK_AspNetUserRoles_AspNetRoles_RoleId", 125 | column: x => x.RoleId, 126 | principalTable: "AspNetRoles", 127 | principalColumn: "Id", 128 | onDelete: ReferentialAction.Cascade); 129 | table.ForeignKey( 130 | name: "FK_AspNetUserRoles_AspNetUsers_UserId", 131 | column: x => x.UserId, 132 | principalTable: "AspNetUsers", 133 | principalColumn: "Id", 134 | onDelete: ReferentialAction.Cascade); 135 | }); 136 | 137 | migrationBuilder.CreateTable( 138 | name: "AspNetUserTokens", 139 | columns: table => new 140 | { 141 | UserId = table.Column(nullable: false), 142 | LoginProvider = table.Column(nullable: false), 143 | Name = table.Column(nullable: false), 144 | Value = table.Column(nullable: true) 145 | }, 146 | constraints: table => 147 | { 148 | table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); 149 | table.ForeignKey( 150 | name: "FK_AspNetUserTokens_AspNetUsers_UserId", 151 | column: x => x.UserId, 152 | principalTable: "AspNetUsers", 153 | principalColumn: "Id", 154 | onDelete: ReferentialAction.Cascade); 155 | }); 156 | 157 | migrationBuilder.CreateIndex( 158 | name: "IX_AspNetRoleClaims_RoleId", 159 | table: "AspNetRoleClaims", 160 | column: "RoleId"); 161 | 162 | migrationBuilder.CreateIndex( 163 | name: "RoleNameIndex", 164 | table: "AspNetRoles", 165 | column: "NormalizedName", 166 | unique: true, 167 | filter: "[NormalizedName] IS NOT NULL"); 168 | 169 | migrationBuilder.CreateIndex( 170 | name: "IX_AspNetUserClaims_UserId", 171 | table: "AspNetUserClaims", 172 | column: "UserId"); 173 | 174 | migrationBuilder.CreateIndex( 175 | name: "IX_AspNetUserLogins_UserId", 176 | table: "AspNetUserLogins", 177 | column: "UserId"); 178 | 179 | migrationBuilder.CreateIndex( 180 | name: "IX_AspNetUserRoles_RoleId", 181 | table: "AspNetUserRoles", 182 | column: "RoleId"); 183 | 184 | migrationBuilder.CreateIndex( 185 | name: "EmailIndex", 186 | table: "AspNetUsers", 187 | column: "NormalizedEmail"); 188 | 189 | migrationBuilder.CreateIndex( 190 | name: "UserNameIndex", 191 | table: "AspNetUsers", 192 | column: "NormalizedUserName", 193 | unique: true, 194 | filter: "[NormalizedUserName] IS NOT NULL"); 195 | } 196 | 197 | protected override void Down(MigrationBuilder migrationBuilder) 198 | { 199 | migrationBuilder.DropTable( 200 | name: "AspNetRoleClaims"); 201 | 202 | migrationBuilder.DropTable( 203 | name: "AspNetUserClaims"); 204 | 205 | migrationBuilder.DropTable( 206 | name: "AspNetUserLogins"); 207 | 208 | migrationBuilder.DropTable( 209 | name: "AspNetUserRoles"); 210 | 211 | migrationBuilder.DropTable( 212 | name: "AspNetUserTokens"); 213 | 214 | migrationBuilder.DropTable( 215 | name: "AspNetRoles"); 216 | 217 | migrationBuilder.DropTable( 218 | name: "AspNetUsers"); 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /coderush/Migrations/ApplicationDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using coderush.Data; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage; 8 | using Microsoft.EntityFrameworkCore.Storage.Internal; 9 | using System; 10 | 11 | namespace coderush.Migrations 12 | { 13 | [DbContext(typeof(ApplicationDbContext))] 14 | partial class ApplicationDbContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "2.0.3-rtm-10026") 21 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 22 | 23 | modelBuilder.Entity("coderush.Models.ApplicationUser", b => 24 | { 25 | b.Property("Id") 26 | .ValueGeneratedOnAdd(); 27 | 28 | b.Property("AccessFailedCount"); 29 | 30 | b.Property("ConcurrencyStamp") 31 | .IsConcurrencyToken(); 32 | 33 | b.Property("Email") 34 | .HasMaxLength(256); 35 | 36 | b.Property("EmailConfirmed"); 37 | 38 | b.Property("LockoutEnabled"); 39 | 40 | b.Property("LockoutEnd"); 41 | 42 | b.Property("NormalizedEmail") 43 | .HasMaxLength(256); 44 | 45 | b.Property("NormalizedUserName") 46 | .HasMaxLength(256); 47 | 48 | b.Property("PasswordHash"); 49 | 50 | b.Property("PhoneNumber"); 51 | 52 | b.Property("PhoneNumberConfirmed"); 53 | 54 | b.Property("SecurityStamp"); 55 | 56 | b.Property("TwoFactorEnabled"); 57 | 58 | b.Property("UserName") 59 | .HasMaxLength(256); 60 | 61 | b.HasKey("Id"); 62 | 63 | b.HasIndex("NormalizedEmail") 64 | .HasName("EmailIndex"); 65 | 66 | b.HasIndex("NormalizedUserName") 67 | .IsUnique() 68 | .HasName("UserNameIndex") 69 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 70 | 71 | b.ToTable("AspNetUsers"); 72 | }); 73 | 74 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 75 | { 76 | b.Property("Id") 77 | .ValueGeneratedOnAdd(); 78 | 79 | b.Property("ConcurrencyStamp") 80 | .IsConcurrencyToken(); 81 | 82 | b.Property("Name") 83 | .HasMaxLength(256); 84 | 85 | b.Property("NormalizedName") 86 | .HasMaxLength(256); 87 | 88 | b.HasKey("Id"); 89 | 90 | b.HasIndex("NormalizedName") 91 | .IsUnique() 92 | .HasName("RoleNameIndex") 93 | .HasFilter("[NormalizedName] IS NOT NULL"); 94 | 95 | b.ToTable("AspNetRoles"); 96 | }); 97 | 98 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 99 | { 100 | b.Property("Id") 101 | .ValueGeneratedOnAdd(); 102 | 103 | b.Property("ClaimType"); 104 | 105 | b.Property("ClaimValue"); 106 | 107 | b.Property("RoleId") 108 | .IsRequired(); 109 | 110 | b.HasKey("Id"); 111 | 112 | b.HasIndex("RoleId"); 113 | 114 | b.ToTable("AspNetRoleClaims"); 115 | }); 116 | 117 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 118 | { 119 | b.Property("Id") 120 | .ValueGeneratedOnAdd(); 121 | 122 | b.Property("ClaimType"); 123 | 124 | b.Property("ClaimValue"); 125 | 126 | b.Property("UserId") 127 | .IsRequired(); 128 | 129 | b.HasKey("Id"); 130 | 131 | b.HasIndex("UserId"); 132 | 133 | b.ToTable("AspNetUserClaims"); 134 | }); 135 | 136 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 137 | { 138 | b.Property("LoginProvider"); 139 | 140 | b.Property("ProviderKey"); 141 | 142 | b.Property("ProviderDisplayName"); 143 | 144 | b.Property("UserId") 145 | .IsRequired(); 146 | 147 | b.HasKey("LoginProvider", "ProviderKey"); 148 | 149 | b.HasIndex("UserId"); 150 | 151 | b.ToTable("AspNetUserLogins"); 152 | }); 153 | 154 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 155 | { 156 | b.Property("UserId"); 157 | 158 | b.Property("RoleId"); 159 | 160 | b.HasKey("UserId", "RoleId"); 161 | 162 | b.HasIndex("RoleId"); 163 | 164 | b.ToTable("AspNetUserRoles"); 165 | }); 166 | 167 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 168 | { 169 | b.Property("UserId"); 170 | 171 | b.Property("LoginProvider"); 172 | 173 | b.Property("Name"); 174 | 175 | b.Property("Value"); 176 | 177 | b.HasKey("UserId", "LoginProvider", "Name"); 178 | 179 | b.ToTable("AspNetUserTokens"); 180 | }); 181 | 182 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 183 | { 184 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") 185 | .WithMany() 186 | .HasForeignKey("RoleId") 187 | .OnDelete(DeleteBehavior.Cascade); 188 | }); 189 | 190 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 191 | { 192 | b.HasOne("coderush.Models.ApplicationUser") 193 | .WithMany() 194 | .HasForeignKey("UserId") 195 | .OnDelete(DeleteBehavior.Cascade); 196 | }); 197 | 198 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 199 | { 200 | b.HasOne("coderush.Models.ApplicationUser") 201 | .WithMany() 202 | .HasForeignKey("UserId") 203 | .OnDelete(DeleteBehavior.Cascade); 204 | }); 205 | 206 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 207 | { 208 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") 209 | .WithMany() 210 | .HasForeignKey("RoleId") 211 | .OnDelete(DeleteBehavior.Cascade); 212 | 213 | b.HasOne("coderush.Models.ApplicationUser") 214 | .WithMany() 215 | .HasForeignKey("UserId") 216 | .OnDelete(DeleteBehavior.Cascade); 217 | }); 218 | 219 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 220 | { 221 | b.HasOne("coderush.Models.ApplicationUser") 222 | .WithMany() 223 | .HasForeignKey("UserId") 224 | .OnDelete(DeleteBehavior.Cascade); 225 | }); 226 | #pragma warning restore 612, 618 227 | } 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/ExternalLoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class ExternalLoginViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/ForgotPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class ForgotPasswordViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/LoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class LoginViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | 15 | [Required] 16 | [DataType(DataType.Password)] 17 | public string Password { get; set; } 18 | 19 | [Display(Name = "Remember me?")] 20 | public bool RememberMe { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/LoginWith2faViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class LoginWith2faViewModel 10 | { 11 | [Required] 12 | [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 13 | [DataType(DataType.Text)] 14 | [Display(Name = "Authenticator code")] 15 | public string TwoFactorCode { get; set; } 16 | 17 | [Display(Name = "Remember this machine")] 18 | public bool RememberMachine { get; set; } 19 | 20 | public bool RememberMe { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/LoginWithRecoveryCodeViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class LoginWithRecoveryCodeViewModel 10 | { 11 | [Required] 12 | [DataType(DataType.Text)] 13 | [Display(Name = "Recovery Code")] 14 | public string RecoveryCode { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/RegisterViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class RegisterViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | [Display(Name = "Email")] 14 | public string Email { get; set; } 15 | 16 | [Required] 17 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "Password")] 20 | public string Password { get; set; } 21 | 22 | [DataType(DataType.Password)] 23 | [Display(Name = "Confirm password")] 24 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 25 | public string ConfirmPassword { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coderush/Models/AccountViewModels/ResetPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.AccountViewModels 8 | { 9 | public class ResetPasswordViewModel 10 | { 11 | [Required] 12 | [EmailAddress] 13 | public string Email { get; set; } 14 | 15 | [Required] 16 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 17 | [DataType(DataType.Password)] 18 | public string Password { get; set; } 19 | 20 | [DataType(DataType.Password)] 21 | [Display(Name = "Confirm password")] 22 | [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 23 | public string ConfirmPassword { get; set; } 24 | 25 | public string Code { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coderush/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Identity; 6 | 7 | namespace coderush.Models 8 | { 9 | // Add profile data for application users by adding properties to the ApplicationUser class 10 | public class ApplicationUser : IdentityUser 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /coderush/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace coderush.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/ChangePasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class ChangePasswordViewModel 10 | { 11 | [Required] 12 | [DataType(DataType.Password)] 13 | [Display(Name = "Current password")] 14 | public string OldPassword { get; set; } 15 | 16 | [Required] 17 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 18 | [DataType(DataType.Password)] 19 | [Display(Name = "New password")] 20 | public string NewPassword { get; set; } 21 | 22 | [DataType(DataType.Password)] 23 | [Display(Name = "Confirm new password")] 24 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 25 | public string ConfirmPassword { get; set; } 26 | 27 | public string StatusMessage { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/EnableAuthenticatorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Mvc.ModelBinding; 8 | 9 | namespace coderush.Models.ManageViewModels 10 | { 11 | public class EnableAuthenticatorViewModel 12 | { 13 | [Required] 14 | [StringLength(7, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 15 | [DataType(DataType.Text)] 16 | [Display(Name = "Verification Code")] 17 | public string Code { get; set; } 18 | 19 | [BindNever] 20 | public string SharedKey { get; set; } 21 | 22 | [BindNever] 23 | public string AuthenticatorUri { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/ExternalLoginsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Authentication; 6 | using Microsoft.AspNetCore.Identity; 7 | 8 | namespace coderush.Models.ManageViewModels 9 | { 10 | public class ExternalLoginsViewModel 11 | { 12 | public IList CurrentLogins { get; set; } 13 | 14 | public IList OtherLogins { get; set; } 15 | 16 | public bool ShowRemoveButton { get; set; } 17 | 18 | public string StatusMessage { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/IndexViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class IndexViewModel 10 | { 11 | public string Username { get; set; } 12 | 13 | public bool IsEmailConfirmed { get; set; } 14 | 15 | [Required] 16 | [EmailAddress] 17 | public string Email { get; set; } 18 | 19 | [Phone] 20 | [Display(Name = "Phone number")] 21 | public string PhoneNumber { get; set; } 22 | 23 | public string StatusMessage { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/RemoveLoginViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class RemoveLoginViewModel 10 | { 11 | public string LoginProvider { get; set; } 12 | public string ProviderKey { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/SetPasswordViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class SetPasswordViewModel 10 | { 11 | [Required] 12 | [StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)] 13 | [DataType(DataType.Password)] 14 | [Display(Name = "New password")] 15 | public string NewPassword { get; set; } 16 | 17 | [DataType(DataType.Password)] 18 | [Display(Name = "Confirm new password")] 19 | [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] 20 | public string ConfirmPassword { get; set; } 21 | 22 | public string StatusMessage { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/ShowRecoveryCodesViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class ShowRecoveryCodesViewModel 10 | { 11 | public string[] RecoveryCodes { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /coderush/Models/ManageViewModels/TwoFactorAuthenticationViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace coderush.Models.ManageViewModels 8 | { 9 | public class TwoFactorAuthenticationViewModel 10 | { 11 | public bool HasAuthenticator { get; set; } 12 | 13 | public int RecoveryCodesLeft { get; set; } 14 | 15 | public bool Is2faEnabled { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /coderush/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace coderush 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | BuildWebHost(args).Run(); 18 | } 19 | 20 | public static IWebHost BuildWebHost(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup() 23 | .Build(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coderush/ScaffoldingReadMe.txt: -------------------------------------------------------------------------------- 1 | Scaffolding has generated all the files and added the required dependencies. 2 | 3 | However the Application's Startup code may required additional changes for things to work end to end. 4 | Add the following code to the Configure method in your Application's Startup class if not already done: 5 | 6 | app.UseMvc(routes => 7 | { 8 | route.MapRoute( 9 | name : "areas", 10 | template : "{area:exists}/{controller=Home}/{action=Index}/{id?}" 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /coderush/Services/EmailSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace coderush.Services 7 | { 8 | // This class is used by the application to send email for account confirmation and password reset. 9 | // For more details see https://go.microsoft.com/fwlink/?LinkID=532713 10 | public class EmailSender : IEmailSender 11 | { 12 | public Task SendEmailAsync(string email, string subject, string message) 13 | { 14 | return Task.CompletedTask; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /coderush/Services/IEmailSender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace coderush.Services 7 | { 8 | public interface IEmailSender 9 | { 10 | Task SendEmailAsync(string email, string subject, string message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /coderush/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.AspNetCore.Identity; 7 | using Microsoft.EntityFrameworkCore; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using coderush.Data; 12 | using coderush.Models; 13 | using coderush.Services; 14 | 15 | namespace coderush 16 | { 17 | public class Startup 18 | { 19 | public Startup(IConfiguration configuration) 20 | { 21 | Configuration = configuration; 22 | } 23 | 24 | public IConfiguration Configuration { get; } 25 | 26 | // This method gets called by the runtime. Use this method to add services to the container. 27 | public void ConfigureServices(IServiceCollection services) 28 | { 29 | services.AddDbContext(options => 30 | options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); 31 | 32 | services.AddIdentity(options => 33 | { 34 | // Password settings 35 | options.Password.RequireDigit = false; 36 | options.Password.RequiredLength = 3; 37 | options.Password.RequireNonAlphanumeric = false; 38 | options.Password.RequireUppercase = false; 39 | options.Password.RequireLowercase = false; 40 | options.Password.RequiredUniqueChars = 0; 41 | 42 | }) 43 | .AddEntityFrameworkStores() 44 | .AddDefaultTokenProviders(); 45 | 46 | // Add application services. 47 | services.AddTransient(); 48 | 49 | services.AddMvc(); 50 | } 51 | 52 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 53 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 54 | { 55 | if (env.IsDevelopment()) 56 | { 57 | app.UseBrowserLink(); 58 | app.UseDeveloperExceptionPage(); 59 | app.UseDatabaseErrorPage(); 60 | } 61 | else 62 | { 63 | app.UseExceptionHandler("/Home/Error"); 64 | } 65 | 66 | app.UseStaticFiles(); 67 | 68 | app.UseAuthentication(); 69 | 70 | app.UseMvc(routes => 71 | { 72 | routes.MapRoute( 73 | name: "areas", 74 | template: "{area:exists}/{controller=Home}/{action=Index}/{id?}" 75 | ); 76 | 77 | routes.MapRoute( 78 | name: "default", 79 | template: "{controller=Home}/{action=Index}/{id?}"); 80 | }); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /coderush/Views/Account/AccessDenied.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Access denied"; 3 | } 4 | 5 |
6 |

@ViewData["Title"]

7 |

You do not have access to this resource.

8 |
9 | -------------------------------------------------------------------------------- /coderush/Views/Account/ConfirmEmail.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Confirm email"; 3 | } 4 | 5 |

@ViewData["Title"]

6 |
7 |

8 | Thank you for confirming your email. 9 |

10 |
11 | -------------------------------------------------------------------------------- /coderush/Views/Account/ExternalLogin.cshtml: -------------------------------------------------------------------------------- 1 | @model ExternalLoginViewModel 2 | @{ 3 | ViewData["Title"] = "Register"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |

Associate your @ViewData["LoginProvider"] account.

8 |
9 | 10 |

11 | You've successfully authenticated with @ViewData["LoginProvider"]. 12 | Please enter an email address for this site below and click the Register button to finish 13 | logging in. 14 |

15 | 16 |
17 |
18 |
19 |
20 |
21 | 22 | 23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 | @section Scripts { 31 | @await Html.PartialAsync("_ValidationScriptsPartial") 32 | } 33 | -------------------------------------------------------------------------------- /coderush/Views/Account/ForgotPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ForgotPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Forgot your password?"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |

Enter your email.

8 |
9 |
10 |
11 |
12 |
13 |
14 | 15 | 16 | 17 |
18 | 19 |
20 |
21 |
22 | 23 | @section Scripts { 24 | @await Html.PartialAsync("_ValidationScriptsPartial") 25 | } 26 | -------------------------------------------------------------------------------- /coderush/Views/Account/ForgotPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Forgot password confirmation"; 3 | } 4 | 5 |

@ViewData["Title"]

6 |

7 | Please check your email to reset your password. 8 |

9 | -------------------------------------------------------------------------------- /coderush/Views/Account/Lockout.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Locked out"; 3 | } 4 | 5 |
6 |

@ViewData["Title"]

7 |

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

8 |
9 | -------------------------------------------------------------------------------- /coderush/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic 2 | @using System.Linq 3 | @using Microsoft.AspNetCore.Http 4 | @using Microsoft.AspNetCore.Http.Authentication 5 | @model LoginViewModel 6 | @inject SignInManager SignInManager 7 | 8 | @{ 9 | ViewData["Title"] = "Log in"; 10 | } 11 | 12 |

@ViewData["Title"]

13 |
14 |
15 |
16 |
17 |

Use a local account to log in.

18 |
19 |
20 |
21 | 22 | 23 | 24 |
25 |
26 | 27 | 28 | 29 |
30 |
31 |
32 | 36 |
37 |
38 |
39 | 40 |
41 |
42 |

43 | Forgot your password? 44 |

45 |

46 | Register as a new user? 47 |

48 |
49 |
50 |
51 |
52 |
53 |
54 |

Use another service to log in.

55 |
56 | @{ 57 | var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList(); 58 | if (loginProviders.Count == 0) 59 | { 60 |
61 |

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

65 |
66 | } 67 | else 68 | { 69 |
70 |
71 |

72 | @foreach (var provider in loginProviders) 73 | { 74 | 75 | } 76 |

77 |
78 |
79 | } 80 | } 81 |
82 |
83 |
84 | 85 | @section Scripts { 86 | @await Html.PartialAsync("_ValidationScriptsPartial") 87 | } 88 | -------------------------------------------------------------------------------- /coderush/Views/Account/LoginWith2fa.cshtml: -------------------------------------------------------------------------------- 1 | @model LoginWith2faViewModel 2 | @{ 3 | ViewData["Title"] = "Two-factor authentication"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |
8 |

Your login is protected with an authenticator app. Enter your authenticator code below.

9 |
10 |
11 |
12 | 13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 |
21 | 25 |
26 |
27 |
28 | 29 |
30 |
31 |
32 |
33 |

34 | Don't have access to your authenticator device? You can 35 | log in with a recovery code. 36 |

37 | 38 | @section Scripts { 39 | @await Html.PartialAsync("_ValidationScriptsPartial") 40 | } -------------------------------------------------------------------------------- /coderush/Views/Account/LoginWithRecoveryCode.cshtml: -------------------------------------------------------------------------------- 1 | @model LoginWithRecoveryCodeViewModel 2 | @{ 3 | ViewData["Title"] = "Recovery code verification"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |
8 |

9 | You have requested to login with a recovery code. This login will not be remembered until you provide 10 | an authenticator app code at login or disable 2FA and login again. 11 |

12 |
13 |
14 |
15 |
16 |
17 | 18 | 19 | 20 |
21 | 22 |
23 |
24 |
25 | 26 | @section Scripts { 27 | @await Html.PartialAsync("_ValidationScriptsPartial") 28 | } -------------------------------------------------------------------------------- /coderush/Views/Account/Register.cshtml: -------------------------------------------------------------------------------- 1 | @model RegisterViewModel 2 | @{ 3 | ViewData["Title"] = "Register"; 4 | } 5 | 6 |

@ViewData["Title"]

7 | 8 |
9 |
10 |
11 |

Create a new account.

12 |
13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 | 30 |
31 |
32 |
33 | 34 | @section Scripts { 35 | @await Html.PartialAsync("_ValidationScriptsPartial") 36 | } 37 | -------------------------------------------------------------------------------- /coderush/Views/Account/ResetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ResetPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Reset password"; 4 | } 5 | 6 |

@ViewData["Title"]

7 |

Reset your password.

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 | @section Scripts { 35 | @await Html.PartialAsync("_ValidationScriptsPartial") 36 | } 37 | -------------------------------------------------------------------------------- /coderush/Views/Account/ResetPasswordConfirmation.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Reset password confirmation"; 3 | } 4 | 5 |

@ViewData["Title"]

6 |

7 | Your password has been reset. Please click here to log in. 8 |

9 | -------------------------------------------------------------------------------- /coderush/Views/Account/SignedOut.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Signed out"; 3 | } 4 | 5 |

@ViewData["Title"]

6 |

7 | You have successfully signed out. 8 |

9 | -------------------------------------------------------------------------------- /coderush/Views/Home/About.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "About"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["Message"]

6 | 7 |

Use this area to provide additional information.

8 | -------------------------------------------------------------------------------- /coderush/Views/Home/Contact.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Contact"; 3 | } 4 |

@ViewData["Title"]

5 |

@ViewData["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 |
18 | -------------------------------------------------------------------------------- /coderush/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 | 67 | 68 | 107 | -------------------------------------------------------------------------------- /coderush/Views/Manage/ChangePassword.cshtml: -------------------------------------------------------------------------------- 1 | @model ChangePasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Change password"; 4 | ViewData.AddActivePage(ManageNavPages.ChangePassword); 5 | } 6 | 7 |

@ViewData["Title"]

8 | @Html.Partial("_StatusMessage", Model.StatusMessage) 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 | @section Scripts { 34 | @await Html.PartialAsync("_ValidationScriptsPartial") 35 | } 36 | -------------------------------------------------------------------------------- /coderush/Views/Manage/Disable2fa.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Disable two-factor authentication (2FA)"; 3 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 4 | } 5 | 6 |

@ViewData["Title"]

7 | 8 | 19 | 20 |
21 |
22 | 23 |
24 |
25 | -------------------------------------------------------------------------------- /coderush/Views/Manage/EnableAuthenticator.cshtml: -------------------------------------------------------------------------------- 1 | @model EnableAuthenticatorViewModel 2 | @{ 3 | ViewData["Title"] = "Enable authenticator"; 4 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 5 | } 6 | 7 |

@ViewData["Title"]

8 |
9 |

To use an authenticator app go through the following steps:

10 |
    11 |
  1. 12 |

    13 | Download a two-factor authenticator app like Microsoft Authenticator for 14 | Windows Phone, 15 | Android and 16 | iOS or 17 | Google Authenticator for 18 | Android and 19 | iOS. 20 |

    21 |
  2. 22 |
  3. 23 |

    Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.

    24 |
    To enable QR code generation please read our documentation.
    25 |
    26 |
    27 |
  4. 28 |
  5. 29 |

    30 | Once you have scanned the QR code or input the key above, your two factor authentication app will provide you 31 | with a unique code. Enter the code in the confirmation box below. 32 |

    33 |
    34 |
    35 |
    36 |
    37 | 38 | 39 | 40 |
    41 | 42 |
    43 |
    44 |
    45 |
    46 |
  6. 47 |
48 |
49 | 50 | @section Scripts { 51 | @await Html.PartialAsync("_ValidationScriptsPartial") 52 | } 53 | -------------------------------------------------------------------------------- /coderush/Views/Manage/ExternalLogins.cshtml: -------------------------------------------------------------------------------- 1 | @model ExternalLoginsViewModel 2 | @{ 3 | ViewData["Title"] = "Manage your external logins"; 4 | ViewData.AddActivePage(ManageNavPages.ExternalLogins); 5 | } 6 | 7 | @Html.Partial("_StatusMessage", Model.StatusMessage) 8 | @if (Model.CurrentLogins?.Count > 0) 9 | { 10 |

Registered Logins

11 | 12 | 13 | @foreach (var login in Model.CurrentLogins) 14 | { 15 | 16 | 17 | 33 | 34 | } 35 | 36 |
@login.LoginProvider 18 | @if (Model.ShowRemoveButton) 19 | { 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | } 28 | else 29 | { 30 | @:   31 | } 32 |
37 | } 38 | @if (Model.OtherLogins?.Count > 0) 39 | { 40 |

Add another service to log in.

41 |
42 |
43 |
44 |

45 | @foreach (var provider in Model.OtherLogins) 46 | { 47 | 48 | } 49 |

50 |
51 |
52 | } 53 | -------------------------------------------------------------------------------- /coderush/Views/Manage/GenerateRecoveryCodes.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Generate two-factor authentication (2FA) recovery codes"; 3 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 4 | } 5 | 6 |

@ViewData["Title"]

7 | 8 | 21 | 22 |
23 |
24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /coderush/Views/Manage/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IndexViewModel 2 | @{ 3 | ViewData["Title"] = "Profile"; 4 | ViewData.AddActivePage(ManageNavPages.Index); 5 | } 6 | 7 |

@ViewData["Title"]

8 | @Html.Partial("_StatusMessage", Model.StatusMessage) 9 |
10 |
11 |
12 |
13 |
14 | 15 | 16 |
17 |
18 | 19 | @if (Model.IsEmailConfirmed) 20 | { 21 |
22 | 23 | 24 |
25 | } 26 | else 27 | { 28 | 29 | 30 | } 31 | 32 |
33 |
34 | 35 | 36 | 37 |
38 | 39 |
40 |
41 |
42 | 43 | @section Scripts { 44 | @await Html.PartialAsync("_ValidationScriptsPartial") 45 | } 46 | -------------------------------------------------------------------------------- /coderush/Views/Manage/ManageNavPages.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc.Rendering; 6 | using Microsoft.AspNetCore.Mvc.ViewFeatures; 7 | 8 | namespace coderush.Views.Manage 9 | { 10 | public static class ManageNavPages 11 | { 12 | public static string ActivePageKey => "ActivePage"; 13 | 14 | public static string Index => "Index"; 15 | 16 | public static string ChangePassword => "ChangePassword"; 17 | 18 | public static string ExternalLogins => "ExternalLogins"; 19 | 20 | public static string TwoFactorAuthentication => "TwoFactorAuthentication"; 21 | 22 | public static string IndexNavClass(ViewContext viewContext) => PageNavClass(viewContext, Index); 23 | 24 | public static string ChangePasswordNavClass(ViewContext viewContext) => PageNavClass(viewContext, ChangePassword); 25 | 26 | public static string ExternalLoginsNavClass(ViewContext viewContext) => PageNavClass(viewContext, ExternalLogins); 27 | 28 | public static string TwoFactorAuthenticationNavClass(ViewContext viewContext) => PageNavClass(viewContext, TwoFactorAuthentication); 29 | 30 | public static string PageNavClass(ViewContext viewContext, string page) 31 | { 32 | var activePage = viewContext.ViewData["ActivePage"] as string; 33 | return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null; 34 | } 35 | 36 | public static void AddActivePage(this ViewDataDictionary viewData, string activePage) => viewData[ActivePageKey] = activePage; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /coderush/Views/Manage/ResetAuthenticator.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Reset authenticator key"; 3 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 4 | } 5 | 6 |

@ViewData["Title"]

7 | 17 |
18 |
19 | 20 |
21 |
-------------------------------------------------------------------------------- /coderush/Views/Manage/SetPassword.cshtml: -------------------------------------------------------------------------------- 1 | @model SetPasswordViewModel 2 | @{ 3 | ViewData["Title"] = "Set password"; 4 | ViewData.AddActivePage(ManageNavPages.ChangePassword); 5 | } 6 | 7 |

Set your password

8 | @Html.Partial("_StatusMessage", Model.StatusMessage) 9 |

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

13 |
14 |
15 |
16 |
17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 | 28 |
29 |
30 |
31 | 32 | @section Scripts { 33 | @await Html.PartialAsync("_ValidationScriptsPartial") 34 | } 35 | -------------------------------------------------------------------------------- /coderush/Views/Manage/ShowRecoveryCodes.cshtml: -------------------------------------------------------------------------------- 1 | @model ShowRecoveryCodesViewModel 2 | @{ 3 | ViewData["Title"] = "Recovery codes"; 4 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 5 | } 6 | 7 |

@ViewData["Title"]

8 | 17 |
18 |
19 | @for (var row = 0; row < Model.RecoveryCodes.Length; row += 2) 20 | { 21 | @Model.RecoveryCodes[row] @Model.RecoveryCodes[row + 1]
22 | } 23 |
24 |
-------------------------------------------------------------------------------- /coderush/Views/Manage/TwoFactorAuthentication.cshtml: -------------------------------------------------------------------------------- 1 | @model TwoFactorAuthenticationViewModel 2 | @{ 3 | ViewData["Title"] = "Two-factor authentication"; 4 | ViewData.AddActivePage(ManageNavPages.TwoFactorAuthentication); 5 | } 6 | 7 |

@ViewData["Title"]

8 | @if (Model.Is2faEnabled) 9 | { 10 | if (Model.RecoveryCodesLeft == 0) 11 | { 12 |
13 | You have no recovery codes left. 14 |

You must generate a new set of recovery codes before you can log in with a recovery code.

15 |
16 | } 17 | else if (Model.RecoveryCodesLeft == 1) 18 | { 19 |
20 | You have 1 recovery code left. 21 |

You can generate a new set of recovery codes.

22 |
23 | } 24 | else if (Model.RecoveryCodesLeft <= 3) 25 | { 26 |
27 | You have @Model.RecoveryCodesLeft recovery codes left. 28 |

You should generate a new set of recovery codes.

29 |
30 | } 31 | 32 | Disable 2FA 33 | Reset recovery codes 34 | } 35 | 36 |
Authenticator app
37 | @if (!Model.HasAuthenticator) 38 | { 39 | Add authenticator app 40 | } 41 | else 42 | { 43 | Configure authenticator app 44 | Reset authenticator key 45 | } 46 | 47 | @section Scripts { 48 | @await Html.PartialAsync("_ValidationScriptsPartial") 49 | } 50 | -------------------------------------------------------------------------------- /coderush/Views/Manage/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | 5 |

Manage your account

6 | 7 |
8 |

Change your account settings

9 |
10 |
11 |
12 | @await Html.PartialAsync("_ManageNav") 13 |
14 |
15 | @RenderBody() 16 |
17 |
18 |
19 | 20 | @section Scripts { 21 | @RenderSection("Scripts", required: false) 22 | } 23 | 24 | -------------------------------------------------------------------------------- /coderush/Views/Manage/_ManageNav.cshtml: -------------------------------------------------------------------------------- 1 | @using coderush.Views.Manage 2 | @inject SignInManager SignInManager 3 | @{ 4 | var hasExternalLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()).Any(); 5 | } 6 | 7 | 16 | 17 | -------------------------------------------------------------------------------- /coderush/Views/Manage/_StatusMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model string 2 | 3 | @if (!String.IsNullOrEmpty(Model)) 4 | { 5 | var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success"; 6 | 10 | } 11 | -------------------------------------------------------------------------------- /coderush/Views/Manage/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using coderush.Views.Manage -------------------------------------------------------------------------------- /coderush/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /coderush/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - coderush 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 42 |
43 | @RenderBody() 44 |
45 |
46 |

© 2018 - coderush

47 |
48 |
49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 62 | 68 | 69 | 70 | 71 | @RenderSection("Scripts", required: false) 72 | 73 | 74 | -------------------------------------------------------------------------------- /coderush/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using coderush.Models 3 | 4 | @inject SignInManager SignInManager 5 | @inject UserManager UserManager 6 | 7 | @if (SignInManager.IsSignedIn(User)) 8 | { 9 | 19 | } 20 | else 21 | { 22 | 26 | } 27 | -------------------------------------------------------------------------------- /coderush/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /coderush/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @using coderush 3 | @using coderush.Models 4 | @using coderush.Models.AccountViewModels 5 | @using coderush.Models.ManageViewModels 6 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 7 | -------------------------------------------------------------------------------- /coderush/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /coderush/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Debug", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /coderush/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-coderush-87F01EC2-07E8-4156-8D09-7BF8110C31F1;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | }, 5 | "Logging": { 6 | "IncludeScopes": false, 7 | "LogLevel": { 8 | "Default": "Warning" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /coderush/bundleconfig.json: -------------------------------------------------------------------------------- 1 | // Configure bundling and minification for the project. 2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241 3 | [ 4 | { 5 | "outputFileName": "wwwroot/css/site.min.css", 6 | // An array of relative input file paths. Globbing patterns supported 7 | "inputFiles": [ 8 | "wwwroot/css/site.css" 9 | ] 10 | }, 11 | { 12 | "outputFileName": "wwwroot/js/site.min.js", 13 | "inputFiles": [ 14 | "wwwroot/js/site.js" 15 | ], 16 | // Optionally specify minification options 17 | "minify": { 18 | "enabled": true, 19 | "renameLocals": true 20 | }, 21 | // Optionally generate .map file 22 | "sourceMap": false 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /coderush/coderush.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | aspnet-coderush-87F01EC2-07E8-4156-8D09-7BF8110C31F1 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /coderush/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Wrapping element */ 7 | /* Set some basic padding to keep content from hitting the edges */ 8 | .body-content { 9 | padding-left: 15px; 10 | padding-right: 15px; 11 | } 12 | 13 | /* Carousel */ 14 | .carousel-caption p { 15 | font-size: 20px; 16 | line-height: 1.4; 17 | } 18 | 19 | /* Make .svg files in the carousel display properly in older browsers */ 20 | .carousel-inner .item img[src$=".svg"] { 21 | width: 100%; 22 | } 23 | 24 | /* QR code generator */ 25 | #qrCode { 26 | margin: 15px; 27 | } 28 | 29 | /* Hide/rearrange for smaller screens */ 30 | @media screen and (max-width: 767px) { 31 | /* Hide captions */ 32 | .carousel-caption { 33 | display: none; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /coderush/wwwroot/css/site.min.css: -------------------------------------------------------------------------------- 1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}} -------------------------------------------------------------------------------- /coderush/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/favicon.ico -------------------------------------------------------------------------------- /coderush/wwwroot/images/banner1.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coderush/wwwroot/images/banner2.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coderush/wwwroot/images/banner3.svg: -------------------------------------------------------------------------------- 1 | banner3b -------------------------------------------------------------------------------- /coderush/wwwroot/images/banner4.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /coderush/wwwroot/images/membership.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/images/membership.png -------------------------------------------------------------------------------- /coderush/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Write your JavaScript code. 2 | -------------------------------------------------------------------------------- /coderush/wwwroot/js/site.min.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/js/site.min.js -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 3" 33 | }, 34 | "version": "3.3.7", 35 | "_release": "3.3.7", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.7", 39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86" 40 | }, 41 | "_source": "https://github.com/twbs/bootstrap.git", 42 | "_target": "v3.3.7", 43 | "_originalSource": "bootstrap", 44 | "_direct": true 45 | } -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2ismail/Asp.Net-Core-Membership-Simple-Example/92cd18d230ece429fb9b80fb7ced80a549f86776/coderush/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /coderush/wwwroot/lib/bootstrap/dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /coderush/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /coderush/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | ** Unobtrusive validation support library for jQuery and jQuery Validate 3 | ** Copyright (C) Microsoft Corporation. All rights reserved. 4 | */ 5 | !function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function m(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=p.unobtrusive.options||{},m=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),m("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),m("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),m("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var u,p=a.validator,v="unobtrusiveValidation";p.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=m(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){p.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=m(this);a&&a.attachValidation()})}},u=p.unobtrusive.adapters,u.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},u.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},u.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},u.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},p.addMethod("__dummy__",function(a,e,n){return!0}),p.addMethod("regex",function(a,e,n){var t;return this.optional(e)?!0:(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),p.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),p.methods.extension?(u.addSingleVal("accept","mimtype"),u.addSingleVal("extension","extension")):u.addSingleVal("extension","extension","accept"),u.addSingleVal("regex","pattern"),u.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),u.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),u.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),u.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),u.add("required",function(a){("INPUT"!==a.element.tagName.toUpperCase()||"CHECKBOX"!==a.element.type.toUpperCase())&&e(a,"required",!0)}),u.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),u.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),a(function(){p.unobtrusive.parse(document)})}(jQuery); -------------------------------------------------------------------------------- /coderush/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /coderush/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /coderush/wwwroot/lib/jquery-validation/dist/additional-methods.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery Validation Plugin - v1.14.0 - 6/30/2015 2 | * http://jqueryvalidation.org/ 3 | * Copyright (c) 2015 Jörn Zaefferer; Licensed MIT */ 4 | !function(a){"function"==typeof define&&define.amd?define(["jquery","./jquery.validate.min"],a):a(jQuery)}(function(a){!function(){function b(a){return a.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g,"")}a.validator.addMethod("maxWords",function(a,c,d){return this.optional(c)||b(a).match(/\b\w+\b/g).length<=d},a.validator.format("Please enter {0} words or less.")),a.validator.addMethod("minWords",function(a,c,d){return this.optional(c)||b(a).match(/\b\w+\b/g).length>=d},a.validator.format("Please enter at least {0} words.")),a.validator.addMethod("rangeWords",function(a,c,d){var e=b(a),f=/\b\w+\b/g;return this.optional(c)||e.match(f).length>=d[0]&&e.match(f).length<=d[1]},a.validator.format("Please enter between {0} and {1} words."))}(),a.validator.addMethod("accept",function(b,c,d){var e,f,g="string"==typeof d?d.replace(/\s/g,"").replace(/,/g,"|"):"image/*",h=this.optional(c);if(h)return h;if("file"===a(c).attr("type")&&(g=g.replace(/\*/g,".*"),c.files&&c.files.length))for(e=0;ec;c++)d=h-c,e=f.substring(c,c+1),g+=d*e;return g%11===0},"Please specify a valid bank account number"),a.validator.addMethod("bankorgiroaccountNL",function(b,c){return this.optional(c)||a.validator.methods.bankaccountNL.call(this,b,c)||a.validator.methods.giroaccountNL.call(this,b,c)},"Please specify a valid bank or giro account number"),a.validator.addMethod("bic",function(a,b){return this.optional(b)||/^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(a)},"Please specify a valid BIC code"),a.validator.addMethod("cifES",function(a){"use strict";var b,c,d,e,f,g,h=[];if(a=a.toUpperCase(),!a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)"))return!1;for(d=0;9>d;d++)h[d]=parseInt(a.charAt(d),10);for(c=h[2]+h[4]+h[6],e=1;8>e;e+=2)f=(2*h[e]).toString(),g=f.charAt(1),c+=parseInt(f.charAt(0),10)+(""===g?0:parseInt(g,10));return/^[ABCDEFGHJNPQRSUVW]{1}/.test(a)?(c+="",b=10-parseInt(c.charAt(c.length-1),10),a+=b,h[8].toString()===String.fromCharCode(64+b)||h[8].toString()===a.charAt(a.length-1)):!1},"Please specify a valid CIF number."),a.validator.addMethod("cpfBR",function(a){if(a=a.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,""),11!==a.length)return!1;var b,c,d,e,f=0;if(b=parseInt(a.substring(9,10),10),c=parseInt(a.substring(10,11),10),d=function(a,b){var c=10*a%11;return(10===c||11===c)&&(c=0),c===b},""===a||"00000000000"===a||"11111111111"===a||"22222222222"===a||"33333333333"===a||"44444444444"===a||"55555555555"===a||"66666666666"===a||"77777777777"===a||"88888888888"===a||"99999999999"===a)return!1;for(e=1;9>=e;e++)f+=parseInt(a.substring(e-1,e),10)*(11-e);if(d(f,b)){for(f=0,e=1;10>=e;e++)f+=parseInt(a.substring(e-1,e),10)*(12-e);return d(f,c)}return!1},"Please specify a valid CPF number"),a.validator.addMethod("creditcardtypes",function(a,b,c){if(/[^0-9\-]+/.test(a))return!1;a=a.replace(/\D/g,"");var d=0;return c.mastercard&&(d|=1),c.visa&&(d|=2),c.amex&&(d|=4),c.dinersclub&&(d|=8),c.enroute&&(d|=16),c.discover&&(d|=32),c.jcb&&(d|=64),c.unknown&&(d|=128),c.all&&(d=255),1&d&&/^(5[12345])/.test(a)?16===a.length:2&d&&/^(4)/.test(a)?16===a.length:4&d&&/^(3[47])/.test(a)?15===a.length:8&d&&/^(3(0[012345]|[68]))/.test(a)?14===a.length:16&d&&/^(2(014|149))/.test(a)?15===a.length:32&d&&/^(6011)/.test(a)?16===a.length:64&d&&/^(3)/.test(a)?16===a.length:64&d&&/^(2131|1800)/.test(a)?15===a.length:128&d?!0:!1},"Please enter a valid credit card number."),a.validator.addMethod("currency",function(a,b,c){var d,e="string"==typeof c,f=e?c:c[0],g=e?!0:c[1];return f=f.replace(/,/g,""),f=g?f+"]":f+"]?",d="^["+f+"([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$",d=new RegExp(d),this.optional(b)||d.test(a)},"Please specify a valid currency"),a.validator.addMethod("dateFA",function(a,b){return this.optional(b)||/^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(a)},a.validator.messages.date),a.validator.addMethod("dateITA",function(a,b){var c,d,e,f,g,h=!1,i=/^\d{1,2}\/\d{1,2}\/\d{4}$/;return i.test(a)?(c=a.split("/"),d=parseInt(c[0],10),e=parseInt(c[1],10),f=parseInt(c[2],10),g=new Date(Date.UTC(f,e-1,d,12,0,0,0)),h=g.getUTCFullYear()===f&&g.getUTCMonth()===e-1&&g.getUTCDate()===d?!0:!1):h=!1,this.optional(b)||h},a.validator.messages.date),a.validator.addMethod("dateNL",function(a,b){return this.optional(b)||/^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(a)},a.validator.messages.date),a.validator.addMethod("extension",function(a,b,c){return c="string"==typeof c?c.replace(/,/g,"|"):"png|jpe?g|gif",this.optional(b)||a.match(new RegExp("\\.("+c+")$","i"))},a.validator.format("Please enter a value with a valid extension.")),a.validator.addMethod("giroaccountNL",function(a,b){return this.optional(b)||/^[0-9]{1,7}$/.test(a)},"Please specify a valid giro account number"),a.validator.addMethod("iban",function(a,b){if(this.optional(b))return!0;var c,d,e,f,g,h,i,j,k,l=a.replace(/ /g,"").toUpperCase(),m="",n=!0,o="",p="";if(c=l.substring(0,2),h={AL:"\\d{8}[\\dA-Z]{16}",AD:"\\d{8}[\\dA-Z]{12}",AT:"\\d{16}",AZ:"[\\dA-Z]{4}\\d{20}",BE:"\\d{12}",BH:"[A-Z]{4}[\\dA-Z]{14}",BA:"\\d{16}",BR:"\\d{23}[A-Z][\\dA-Z]",BG:"[A-Z]{4}\\d{6}[\\dA-Z]{8}",CR:"\\d{17}",HR:"\\d{17}",CY:"\\d{8}[\\dA-Z]{16}",CZ:"\\d{20}",DK:"\\d{14}",DO:"[A-Z]{4}\\d{20}",EE:"\\d{16}",FO:"\\d{14}",FI:"\\d{14}",FR:"\\d{10}[\\dA-Z]{11}\\d{2}",GE:"[\\dA-Z]{2}\\d{16}",DE:"\\d{18}",GI:"[A-Z]{4}[\\dA-Z]{15}",GR:"\\d{7}[\\dA-Z]{16}",GL:"\\d{14}",GT:"[\\dA-Z]{4}[\\dA-Z]{20}",HU:"\\d{24}",IS:"\\d{22}",IE:"[\\dA-Z]{4}\\d{14}",IL:"\\d{19}",IT:"[A-Z]\\d{10}[\\dA-Z]{12}",KZ:"\\d{3}[\\dA-Z]{13}",KW:"[A-Z]{4}[\\dA-Z]{22}",LV:"[A-Z]{4}[\\dA-Z]{13}",LB:"\\d{4}[\\dA-Z]{20}",LI:"\\d{5}[\\dA-Z]{12}",LT:"\\d{16}",LU:"\\d{3}[\\dA-Z]{13}",MK:"\\d{3}[\\dA-Z]{10}\\d{2}",MT:"[A-Z]{4}\\d{5}[\\dA-Z]{18}",MR:"\\d{23}",MU:"[A-Z]{4}\\d{19}[A-Z]{3}",MC:"\\d{10}[\\dA-Z]{11}\\d{2}",MD:"[\\dA-Z]{2}\\d{18}",ME:"\\d{18}",NL:"[A-Z]{4}\\d{10}",NO:"\\d{11}",PK:"[\\dA-Z]{4}\\d{16}",PS:"[\\dA-Z]{4}\\d{21}",PL:"\\d{24}",PT:"\\d{21}",RO:"[A-Z]{4}[\\dA-Z]{16}",SM:"[A-Z]\\d{10}[\\dA-Z]{12}",SA:"\\d{2}[\\dA-Z]{18}",RS:"\\d{18}",SK:"\\d{20}",SI:"\\d{15}",ES:"\\d{20}",SE:"\\d{20}",CH:"\\d{5}[\\dA-Z]{12}",TN:"\\d{20}",TR:"\\d{5}[\\dA-Z]{17}",AE:"\\d{3}\\d{16}",GB:"[A-Z]{4}\\d{14}",VG:"[\\dA-Z]{4}\\d{16}"},g=h[c],"undefined"!=typeof g&&(i=new RegExp("^[A-Z]{2}\\d{2}"+g+"$",""),!i.test(l)))return!1;for(d=l.substring(4,l.length)+l.substring(0,4),j=0;j9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/)},"Please specify a valid mobile number"),a.validator.addMethod("nieES",function(a){"use strict";return a=a.toUpperCase(),a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")?/^[T]{1}/.test(a)?a[8]===/^[T]{1}[A-Z0-9]{8}$/.test(a):/^[XYZ]{1}/.test(a)?a[8]==="TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.replace("X","0").replace("Y","1").replace("Z","2").substring(0,8)%23):!1:!1},"Please specify a valid NIE number."),a.validator.addMethod("nifES",function(a){"use strict";return a=a.toUpperCase(),a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")?/^[0-9]{8}[A-Z]{1}$/.test(a)?"TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.substring(8,0)%23)===a.charAt(8):/^[KLM]{1}/.test(a)?a[8]===String.fromCharCode(64):!1:!1},"Please specify a valid NIF number."),jQuery.validator.addMethod("notEqualTo",function(b,c,d){return this.optional(c)||!a.validator.methods.equalTo.call(this,b,c,d)},"Please enter a different value, values must not be the same."),a.validator.addMethod("nowhitespace",function(a,b){return this.optional(b)||/^\S+$/i.test(a)},"No white space please"),a.validator.addMethod("pattern",function(a,b,c){return this.optional(b)?!0:("string"==typeof c&&(c=new RegExp("^(?:"+c+")$")),c.test(a))},"Invalid format."),a.validator.addMethod("phoneNL",function(a,b){return this.optional(b)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(a)},"Please specify a valid phone number."),a.validator.addMethod("phoneUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/)},"Please specify a valid phone number"),a.validator.addMethod("phoneUS",function(a,b){return a=a.replace(/\s+/g,""),this.optional(b)||a.length>9&&a.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]([02-9]\d|1[02-9])-?\d{4}$/)},"Please specify a valid phone number"),a.validator.addMethod("phonesUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/)},"Please specify a valid uk phone number"),a.validator.addMethod("postalCodeCA",function(a,b){return this.optional(b)||/^[ABCEGHJKLMNPRSTVXY]\d[A-Z] \d[A-Z]\d$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeBR",function(a,b){return this.optional(b)||/^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(a)},"Informe um CEP válido."),a.validator.addMethod("postalcodeIT",function(a,b){return this.optional(b)||/^\d{5}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeNL",function(a,b){return this.optional(b)||/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postcodeUK",function(a,b){return this.optional(b)||/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(a)},"Please specify a valid UK postcode"),a.validator.addMethod("require_from_group",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_req_grp")?f.data("valid_req_grp"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length>=d[0];return f.data("valid_req_grp",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),h},a.validator.format("Please fill at least {0} of these fields.")),a.validator.addMethod("skip_or_fill_minimum",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_skip")?f.data("valid_skip"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length,i=0===h||h>=d[0];return f.data("valid_skip",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),i},a.validator.format("Please either skip these fields or fill at least {0} of them.")),a.validator.addMethod("stateUS",function(a,b,c){var d,e="undefined"==typeof c,f=e||"undefined"==typeof c.caseSensitive?!1:c.caseSensitive,g=e||"undefined"==typeof c.includeTerritories?!1:c.includeTerritories,h=e||"undefined"==typeof c.includeMilitary?!1:c.includeMilitary;return d=g||h?g&&h?"^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":g?"^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":"^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$":"^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$",d=f?new RegExp(d):new RegExp(d,"i"),this.optional(b)||d.test(a)},"Please specify a valid state"),a.validator.addMethod("strippedminlength",function(b,c,d){return a(b).text().length>=d},a.validator.format("Please enter at least {0} characters")),a.validator.addMethod("time",function(a,b){return this.optional(b)||/^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(a)},"Please enter a valid time, between 00:00 and 23:59"),a.validator.addMethod("time12h",function(a,b){return this.optional(b)||/^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(a)},"Please enter a valid time in 12-hour am/pm format"),a.validator.addMethod("url2",function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},a.validator.messages.url),a.validator.addMethod("vinUS",function(a){if(17!==a.length)return!1;var b,c,d,e,f,g,h=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"],i=[1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9],j=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],k=0;for(b=0;17>b;b++){if(e=j[b],d=a.slice(b,b+1),8===b&&(g=d),isNaN(d)){for(c=0;c