Beispiel #1
0
    private void DoActivate()
    {
        mvwLogin.ActiveViewIndex = 1;

        string activationkey = Request.QueryString["activationkey"];
        if (!string.IsNullOrEmpty(activationkey))
        {
            Guid key = new Guid(activationkey);
            using (UltimateDataContext dc = new UltimateDataContext())
            {
                var user = (from p in dc.PlaceberryUsers
                            where p.ActivationKey.HasValue && p.ActivationKey.Value == key
                            select p).SingleOrDefault();

                if (user != null)
                {
                    user.aspnet_User.aspnet_Membership.IsApproved = true;
                    user.ActivationKey = null;

                    dc.SubmitChanges();

                    FormsAuthentication.SetAuthCookie(user.aspnet_User.UserName, true);

                    ltlSucess.Visible = true;

                    Response.AddHeader("REFRESH", "3;URL=/manage");
                }
                else
                {
                    ltlError.Visible = true;
                }
            }
        }
        else
        {
            ltlError.Visible = true;
        }
    }
Beispiel #2
0
    private void CreatePlaceberryUser(MembershipUser user)
    {
        using (UltimateDataContext dc = new UltimateDataContext())
        {
            PlaceberryUser newuser = new PlaceberryUser();
            newuser.UserId = (Guid)user.ProviderUserKey;
            newuser.ActivationKey = Guid.NewGuid();

            dc.PlaceberryUsers.InsertOnSubmit(newuser);
            dc.SubmitChanges();

            SendActivationEmailToUser(user, newuser.ActivationKey.Value.ToString());
        }
    }