示例#1
0
        public ActionResult ImportAspNetUserSubmit(string email, string salt, string password)
        {
            if (email.IsNullOrEmpty() || salt.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                return(Content("Missing required value", "text/html"));
            }

            // Prevents us from creating any user we wouldn't do otherwise
            string token, authCode, error;

            if (!PendingUser.CreatePendingUser(email, Guid.NewGuid().ToString(), null, out token, out authCode, out error))
            {
                return(Content("<font color='red'>For [" + email + "] - " + error + "</font>", "text/html"));
            }

            // Change the u/p to what's expected
            var pending = Current.WriteDB.PendingUsers.Single(u => u.AuthCode == authCode);

            pending.PasswordSalt = salt;
            pending.PasswordHash = password;
            Current.WriteDB.SubmitChanges();

            User newUser;

            if (!Models.User.CreateAccount(email, pending, Current.Now, null, null, out newUser, out error))
            {
                return(Content("<font color='red'>For [" + email + "] and PendingUser.Id = " + pending.Id + " - " + error + "</font>", "text/html"));
            }

            // And indicate that this is from ASP.NET Membership
            newUser.PasswordVersion = MembershipCompat.PasswordVersion;
            Current.WriteDB.SubmitChanges();

            return(Content("[" + email + "] became <a href='" + newUser.GetClaimedIdentifier() + "'>user</a>", "text/html"));
        }
示例#2
0
        public ActionResult SendEmailVerficationToken(string email, string password, string password2, string realname)
        {
            if (email.IsNullOrEmpty())
            {
                return(RecoverableError("Email is required", new { realname }));
            }
            if (!Models.User.IsValidEmail(ref email))
            {
                return(RecoverableError("Email is not valid", new { email, realname, password, password2 }));
            }

            // Check that the captcha succeeded
            string error;

            if (!Captcha.Verify(Request.Form, out error))
            {
                return(RecoverableError(error, new { email, realname }));
            }

            string message;

            if (!Password.CheckPassword(password, password2, email, null, null, out message))
            {
                return(RecoverableError(message, new { email, realname }));
            }

            string token, authCode;

            if (!PendingUser.CreatePendingUser(email, password, realname, out token, out authCode, out error))
            {
                return(RecoverableError(error, new { email, realname, password, password2 }));
            }

            var toComplete =
                SafeRedirect(
                    (Func <string, string, string, string, ActionResult>)CompleteRegistration,
                    new
            {
                token,
                email,
                realname,
                authCode
            }
                    );

            var completeLink = Current.Url(toComplete.Url);

            if (!Current.Email.SendEmail(email, Email.Template.CompleteRegistration, new { RegistrationLink = completeLink.AsLink() }))
            {
                return(IrrecoverableError("An error occurred sending the email", "This has been recorded, and will be looked into shortly"));
            }

            return(SuccessEmail("Registration Email Sent to " + email, "Check your email for the link to complete your registration"));
        }
示例#3
0
        public ActionResult SignupIFrameSubmit(string email, string password, string password2, string realname, string background, string color)
        {
            if (email.IsNullOrEmpty())
            {
                // Can't use standard RecoverableError things in affiliate forms, do it by hand
                ViewData["error_message"] = "Email is required";
                ViewData["affId"]         = CurrentAffiliate.Id;
                ViewData["realname"]      = realname;
                ViewData["password"]      = password;
                ViewData["password2"]     = password2;

                return(SignupIFrame(null, background, color));
            }

            if (!Models.User.IsValidEmail(ref email))
            {
                // Can't use standard RecoverableError things in affiliate forms, do it by hand
                ViewData["error_message"] = "Email is not valid";
                ViewData["affId"]         = CurrentAffiliate.Id;
                ViewData["realname"]      = realname;
                ViewData["email"]         = email;
                ViewData["password"]      = password;
                ViewData["password2"]     = password2;

                return(SignupIFrame(null, background, color));
            }

            // Check that the captcha succeeded
            string error;

            if (!Captcha.Verify(Request.Form, out error) || !Password.CheckPassword(password, password2, email, null, null, out error))
            {
                // Can't use standard RecoverableError things in affiliate forms, do it by hand
                ViewData["error_message"] = error;
                ViewData["affId"]         = CurrentAffiliate.Id;
                ViewData["email"]         = email;
                ViewData["realname"]      = realname;
                ViewData["password"]      = password;
                ViewData["password2"]     = password2;

                return(SignupIFrame(null, background, color));
            }

            var cookie = System.Web.HttpContext.Current.CookieSentOrReceived(Current.AnonymousCookieName);

            var callback = Current.GetFromCache <string>(CallbackKey(cookie));

            string token, authCode;

            if (!PendingUser.CreatePendingUser(email, password, realname, out token, out authCode, out error))
            {
                // Can't use standard RecoverableError things in affiliate forms, do it by hand
                ViewData["error_message"] = error;
                ViewData["affId"]         = CurrentAffiliate.Id;
                ViewData["email"]         = email;
                ViewData["realname"]      = realname;
                ViewData["password"]      = password;
                ViewData["password2"]     = password2;

                return(SignupIFrame(null, background, color));
            }

            var complete =
                SafeRedirect(
                    (Func <string, string, string, string, string, string, ActionResult>)
                        (new AccountController()).CompleteAffiliateTriggeredRegistration,
                    new
            {
                email,
                affId = CurrentAffiliate.Id,
                token,
                callback,
                realname,
                authCode
            }
                    );

            var completeLink = Current.Url(complete.Url);

            string affName = CurrentAffiliate.HostFilter;
            Uri    callbackUri;

            if (Uri.TryCreate(callback, UriKind.Absolute, out callbackUri))
            {
                affName = callbackUri.Host;
            }

            var success =
                Current.Email.SendEmail(
                    email,
                    Email.Template.CompleteRegistrationViaAffiliate,
                    new {
                AffiliateName    = affName,
                RegistrationLink = completeLink.AsLink()
            });

            if (!success)
            {
                return(IrrecoverableError("An error occurred sending the email", "This has been recorded, and will be looked into shortly"));
            }

            ViewData["Background"] = background;
            ViewData["Color"]      = color;

            return(SuccessEmail("Registration Email Sent to " + email, "Check your email for the link to complete your registration."));
        }