예제 #1
0
        public async Task <ActionResult> Register(string email, string password1, string password2, string name, string company)
        {
            RegisterUser userToRegister = new RegisterUser();

            try
            {
                userToRegister.Setup(email, password1, password2, name, company);
                RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
                if (String.IsNullOrEmpty(recaptchaHelper.Response))
                {
                    throw new CustomException.EmptyRecaptcha();
                }
                RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    throw new CustomException.Recaptcha();
                }
                userToRegister.Save();
                return(View());
            }
            catch (Exception ex)
            {
                if (ex is CustomException.EmptyRecaptcha || ex is CustomException.Recaptcha)
                {
                    userToRegister.Error = ex.Message;
                }
                return(View(userToRegister));
            }
        }