Esempio n. 1
0
        public virtual async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                string recapatchaResponse = Request.Form["g-recaptcha-response"];
                var    result             = await RecaptchaClient.Verify(RecaptchaConfiguration.Instance.SecretKey, recapatchaResponse);

                if (result.success)
                {
                    var statusCode = await RaceDayClient.ForgotPassword(model.RegisterEmail);

                    if (statusCode == HttpStatusCode.OK)
                    {
                        model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.success, "Check your email for your account password.<br />You may change your password after you have <a href=\"/raceday\">logged on</a>.");
                    }
                    else
                    {
                        model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "Could not identify your account.<br />Use the <a href=\"/Logon/Register\">Register Account</a> link to create an account if you have not yet registered.");
                    }
                }
                else
                {
                    model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "Invalid captcha response.");
                }
            }

            return(View(model));
        }
Esempio n. 2
0
        public virtual async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                string recapatchaResponse = Request.Form["g-recaptcha-response"];
                var    result             = await RecaptchaClient.Verify(RecaptchaConfiguration.Instance.SecretKey, recapatchaResponse);

                if (result.success)
                {
                    var resultCode = await RaceDayClient.UserRegister(model.GroupCode, model.FirstName, model.LastName, model.RegisterEmail, model.RegisterPassword);

                    if (resultCode == HttpStatusCode.Created)
                    {
                        var login = await RaceDayClient.Login(model.RegisterEmail.Trim(), model.RegisterPassword.Trim());

                        RaceDayUser.LoginUser(login, false);

                        return(RedirectToAction(MVC.Home.Index()));
                    }
                    else if (resultCode == HttpStatusCode.BadRequest)
                    {
                        model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "Invalid registration request.");
                    }
                    else if (resultCode == HttpStatusCode.Conflict)
                    {
                        model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "Account already exists.");
                    }
                    else
                    {
                        model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "API Server error.");
                    }
                }
                else
                {
                    model.PageMessage = new PageMessageModel(MessageDismissEnum.none, CssMessageClassEnum.error, "Invalid captcha response.");
                }
            }

            return(View(model));
        }