|
6 | 6 | using System.Web; |
7 | 7 | using System.Web.Mvc; |
8 | 8 | using Microsoft.AspNet.Identity; |
| 9 | +using Microsoft.AspNet.Identity.EntityFramework; //import for rolestore |
9 | 10 | using Microsoft.AspNet.Identity.Owin; |
10 | 11 | using Microsoft.Owin.Security; |
11 | 12 | using Vidly3.Models; |
@@ -151,10 +152,24 @@ public async Task<ActionResult> Register(RegisterViewModel model) |
151 | 152 | { |
152 | 153 | if (ModelState.IsValid) |
153 | 154 | { |
154 | | - var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; |
| 155 | + //change this to use DrivingLicense |
| 156 | + var user = new ApplicationUser |
| 157 | + { |
| 158 | + UserName = model.Email, |
| 159 | + Email = model.Email, |
| 160 | + DrivingLicense = model.DrivingLicense, |
| 161 | + Phone = model.Phone |
| 162 | + }; |
155 | 163 | var result = await UserManager.CreateAsync(user, model.Password); |
156 | 164 | if (result.Succeeded) |
157 | 165 | { |
| 166 | + ////next block is temp code for seeding DB. use instead of Seed method |
| 167 | + ////go to app and register afterwards to add an admin role |
| 168 | + //var roleStore = new RoleStore<IdentityRole>(new ApplicationDbContext()); |
| 169 | + //var roleManager = new RoleManager<IdentityRole>(roleStore); |
| 170 | + //await roleManager.CreateAsync(new IdentityRole("CanManageMovies")); |
| 171 | + //await UserManager.AddToRoleAsync(user.Id, "CanManageMovies"); |
| 172 | + |
158 | 173 | await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); |
159 | 174 |
|
160 | 175 | // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 |
@@ -367,7 +382,15 @@ public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmat |
367 | 382 | { |
368 | 383 | return View("ExternalLoginFailure"); |
369 | 384 | } |
370 | | - var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; |
| 385 | + //add license and phone fields manually |
| 386 | + var user = new ApplicationUser |
| 387 | + { |
| 388 | + UserName = model.Email, |
| 389 | + Email = model.Email, |
| 390 | + DrivingLicense = model.DrivingLicense, |
| 391 | + Phone = model.Phone |
| 392 | + }; |
| 393 | + |
371 | 394 | var result = await UserManager.CreateAsync(user); |
372 | 395 | if (result.Succeeded) |
373 | 396 | { |
|
0 commit comments