Exemplo n.º 1
0
        //private string GetUserToken(string email)
        //{
        //    return Membership.Provider.GetUser(email, false).ProviderUserKey.ToString();
        //}

        //private MembershipCreateStatus CreateUser(string userName, string password, string email)
        //{
        //    MembershipCreateStatus status;
        //    Membership.Provider.CreateUser(userName, password, email, null, null, false, null, out status);
        //    return status;
        //}

        //private string ConvertToString(object[] array)
        //{
        //    string s = string.Empty;

        //    foreach (object o in array)
        //    {
        //        s += o.ToString() + ",";
        //    }

        //    return s;
        //}

        protected override void AfterCreateBeforeCommit(CreateEventArgs e)
        {
            //System.Diagnostics.EventLog.WriteEntry("Gear", e.Values.Values.ToArray().ToString());
            //System.Threading.Thread.Sleep(5000);
            //System.Diagnostics.EventLog.WriteEntry("Gear", ConvertToString(e.Values.Values.ToArray()));
            string username  = e.Values["Email"].ToString();
            string email     = e.Values["Email"].ToString();
            string password  = e.Values["Password"].ToString();
            string firstName = e.Values["FirstName"].ToString();
            string lastName  = e.Values["LastName"].ToString();

            System.Web.Security.MembershipCreateStatus status = MembershipService.CreateUser(username, password, email, false);

            if (status == System.Web.Security.MembershipCreateStatus.Success)
            {
                System.Web.Security.Roles.AddUserToRole(username, "User");
            }
            else
            {
                e.Cancel = true;
            }
            base.AfterCreateBeforeCommit(e);

            if (e.Cancel)
            {
                throw new Exception(status.ToString());
            }
            else
            {
                SendAuthenticationEmail(email, firstName, lastName);
            }
        }
Exemplo n.º 2
0
        protected override void AfterCreateBeforeCommit(CreateEventArgs e)
        {
            string username  = e.Values["Email"].ToString();
            string email     = e.Values["Email"].ToString();
            string password  = e.Values["Password"].ToString();
            string firstName = e.Values["FirstName"].ToString();
            string lastName  = e.Values["LastName"].ToString();

            System.Web.Security.MembershipCreateStatus status = MembershipService.CreateUser(username, password, email, false);

            if (status == System.Web.Security.MembershipCreateStatus.Success)
            {
                System.Web.Security.Roles.AddUserToRole(username, "User");
            }
            else
            {
                e.Cancel = true;
            }
            base.AfterCreateBeforeCommit(e);

            if (e.Cancel)
            {
                throw new Exception(status.ToString());
            }
            else
            {
                SendAuthenticationEmail(email, firstName, lastName);
            }
        }
Exemplo n.º 3
0
        protected override void AfterCreateBeforeCommit(CreateEventArgs e)
        {
            string username     = e.Values["Username"].ToString();
            string email        = e.Values["Email"].ToString();
            string tempPassword = "******";

            System.Web.Security.MembershipCreateStatus status = CreateUser(username, tempPassword, email);
            System.Web.Security.Roles.AddUserToRole(username, "User");

            if (status != System.Web.Security.MembershipCreateStatus.Success)
            {
                e.Cancel = true;
            }
            base.AfterCreateBeforeCommit(e);

            if (e.Cancel)
            {
                throw new Exception(status.ToString());
            }
        }