Skip to content

Instantly share code, notes, and snippets.

@sabbour
Last active August 29, 2015 14:03
Show Gist options
  • Save sabbour/cc8dacfd41afbd8b696d to your computer and use it in GitHub Desktop.
Save sabbour/cc8dacfd41afbd8b696d to your computer and use it in GitHub Desktop.
Adding the Country Code, Phone and PIN properties to the ApplicationUser model
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