Last active
August 29, 2015 14:03
-
-
Save sabbour/cc8dacfd41afbd8b696d to your computer and use it in GitHub Desktop.
Adding the Country Code, Phone and PIN properties to the ApplicationUser model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Security.Claims; | |
using System.Threading.Tasks; | |
using Microsoft.AspNet.Identity; | |
using Microsoft.AspNet.Identity.EntityFramework; | |
namespace MFAAuth.Models | |
{ | |
// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. | |
public class ApplicationUser : IdentityUser | |
{ | |
public string CountryCode { get; set; } | |
public string Phone { get; set; } | |
public int PIN { get; set; } | |
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) | |
{ | |
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType | |
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); | |
// Add custom user claims here | |
return userIdentity; | |
} | |
} | |
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> | |
{ | |
public ApplicationDbContext() | |
: base("DefaultConnection", throwIfV1Schema: false) | |
{ | |
} | |
public static ApplicationDbContext Create() | |
{ | |
return new ApplicationDbContext(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment