示例#1
0
文件: WebSecurity.cs 项目: spenar/hts
    public static MembershipCreateStatus Register(string Username, string Password, string Email, bool IsApproved, string FirstName, string LastName)
    {
        MembershipCreateStatus CreateStatus;
            Membership.CreateUser(Username, Password, Email, null, null, IsApproved, Guid.NewGuid(), out CreateStatus);

            if (CreateStatus == MembershipCreateStatus.Success)
            {
                using (HomeTaskContext Context = new HomeTaskContext())
                {
                    User User = Context.Users.FirstOrDefault(Usr => Usr.Username == Username);
                    User.FirstName = FirstName;
                    User.LastName = LastName;
                    Context.SaveChanges();
                }

                if (IsApproved)
                {
                    FormsAuthentication.SetAuthCookie(Username, false);
                }
            }

            return CreateStatus;
    }
示例#2
0
 public CodeFirstRoleProvider()
     : base()
 {
     this.Context = new HomeTaskContext();
 }
示例#3
0
 public CodeFirstMembershipProvider()
     : base()
 {
     this.Context = new HomeTaskContext();
 }