public List <CustomRegistration> GetRegistration(string assessmentID) { List <CustomRegistration> result = new List <CustomRegistration>(); try { var data = examDAL.GetRegistration(new Guid(assessmentID)); foreach (var item in data) { CustomRegistration customRegistration = new CustomRegistration(); customRegistration.AssessmentId = item.AssessmentId; customRegistration.Createddate = item.Createddate; customRegistration.DisplayFieldName = item.DisplayFieldName; customRegistration.FieldName = item.FieldName; customRegistration.FieldType = item.FieldType; customRegistration.FormId = item.FormId; customRegistration.id = item.id; customRegistration.IsEnabled = item.IsEnabled; customRegistration.IsLocked = item.IsLocked; customRegistration.IsMandatory = item.IsMandatory; customRegistration.ModificationHistory = item.ModificationHistory; customRegistration.ModifiedDate = item.ModifiedDate; customRegistration.Remarks = item.Remarks; customRegistration.Values = item.Values; result.Add(customRegistration); } } catch (Exception ex) { throw; } return(result); }
public virtual async Task <IActionResult> Register(string returnUrl = null) { if (AccountService.IsSignedIn(User)) { return(this.RedirectToSiteRoot(CurrentSite)); } if (!CurrentSite.AllowNewRegistration) { return(new StatusCodeResult(404)); } // login is equivalent to register for new social auth users // if db auth is disabled just redirect if (CurrentSite.DisableDbAuth && CurrentSite.HasAnySocialAuthEnabled()) { return(RedirectToAction("Login")); } ViewData["Title"] = StringLocalizer["Register"]; returnUrl = IdentityServerIntegration.EnsureFolderSegmentIfNeeded(CurrentSite, returnUrl); //identityserver integration point var idProvider = await IdentityServerIntegration.GetAuthorizationContextAsync(returnUrl); if (!string.IsNullOrEmpty(idProvider)) { // if IdP is passed, then bypass showing the login screen return(ExternalLogin(idProvider, returnUrl)); } ViewData["ReturnUrl"] = returnUrl; var model = new RegisterViewModel { SiteId = CurrentSite.Id }; if ((CurrentSite.CaptchaOnRegistration) && (!string.IsNullOrWhiteSpace(CurrentSite.RecaptchaPublicKey))) { model.RecaptchaSiteKey = CurrentSite.RecaptchaPublicKey; model.UseInvisibleCaptcha = CurrentSite.UseInvisibleRecaptcha; } model.UseEmailForLogin = CurrentSite.UseEmailForLogin; model.RegistrationPreamble = CurrentSite.RegistrationPreamble; model.RegistrationAgreement = CurrentSite.RegistrationAgreement; model.AgreementRequired = !string.IsNullOrWhiteSpace(CurrentSite.RegistrationAgreement); model.ExternalAuthenticationList = await AccountService.GetExternalAuthenticationSchemes(); var viewName = await CustomRegistration.GetRegisterViewName(CurrentSite, HttpContext); await CustomRegistration.HandleRegisterGet( CurrentSite, model, HttpContext, ViewData); return(View(viewName, model)); }
public virtual async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null) { ViewData["Title"] = StringLocalizer["Register"]; ViewData["ReturnUrl"] = returnUrl; Analytics.HandleRegisterSubmit("Onsite").Forget(); if ((CurrentSite.CaptchaOnRegistration) && (!string.IsNullOrWhiteSpace(CurrentSite.RecaptchaPublicKey))) { model.RecaptchaSiteKey = CurrentSite.RecaptchaPublicKey; model.UseInvisibleCaptcha = CurrentSite.UseInvisibleRecaptcha; } model.UseEmailForLogin = CurrentSite.UseEmailForLogin; model.RegistrationPreamble = CurrentSite.RegistrationPreamble; model.RegistrationAgreement = CurrentSite.RegistrationAgreement; model.AgreementRequired = !string.IsNullOrWhiteSpace(CurrentSite.RegistrationAgreement); model.ExternalAuthenticationList = await AccountService.GetExternalAuthenticationSchemes(); bool isValid = ModelState.IsValid; bool customDataIsValid = await CustomRegistration.HandleRegisterValidation( CurrentSite, model, HttpContext, ViewData, ModelState); if (isValid && customDataIsValid) { if ((CurrentSite.CaptchaOnRegistration) && (!string.IsNullOrWhiteSpace(CurrentSite.RecaptchaPublicKey))) { var captchaResponse = await RecaptchaServerSideValidator.ValidateRecaptcha(Request, CurrentSite.RecaptchaPrivateKey); if (!captchaResponse.Success) { ModelState.AddModelError("recaptchaerror", StringLocalizer["reCAPTCHA Error occured. Please try again"]); isValid = false; } } if (!string.IsNullOrWhiteSpace(CurrentSite.RegistrationAgreement)) { if (!model.AgreeToTerms) { ModelState.AddModelError("agreementerror", StringLocalizer["You must agree to the terms"]); isValid = false; } } var viewName = await CustomRegistration.GetRegisterViewName(CurrentSite, HttpContext); if (!isValid || !customDataIsValid) { return(View(viewName, model)); } var result = await AccountService.TryRegister(model, ModelState, HttpContext, CustomRegistration); if (result.SignInResult.Succeeded || (result.SignInResult.IsNotAllowed && result.User != null)) { await CustomRegistration.HandleRegisterPostSuccess( CurrentSite, model, HttpContext, result); if (result.SignInResult.Succeeded) { return(await HandleLoginSuccess(result, returnUrl)); } } foreach (var reason in result.RejectReasons) { //these reasons are not meant to be shown in the ui // but we can log them so admin will see failed attempts in the log along with reasons Log.LogWarning(reason); } if (result.SignInResult.IsNotAllowed) { return(await HandleLoginNotAllowed(result, returnUrl)); } var te = result.RejectReasons.FirstOrDefault(); if (string.IsNullOrEmpty(te)) { te = "unknown"; } Analytics.HandleRegisterFail("Onsite", te).Forget(); Log.LogInformation($"registration did not succeed for {model.Email}"); // ModelState.AddModelError(string.Empty, sr["Invalid registration attempt."]); return(View(viewName, model)); } var errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0).Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage }); var trackedError = errors.FirstOrDefault().errorMessage; Analytics.HandleRegisterFail("Onsite", trackedError).Forget(); // If we got this far, something failed, redisplay form return(View(model)); }
public void SetUp() { _registration = new CustomRegistration(); }
public void SetUp() { _serviceManager = new ServiceManager(); _registration = new CustomRegistration(); _serviceManager.RegisterBootstrap(BootstrapRegistration.For <IRegistration>(_registration)); }