public async Task <IActionResult> OnGetAsync(string id) { var image = await _imagesService.FindByIdAsync(id); if (image == null) { return(NotFound()); } PageTitle = await TranslationsService.TranslateAsync("images"); TitleDisplay = await TranslationsService.TranslateAsync("title"); ImageDisplay = await TranslationsService.TranslateAsync("image"); TitleRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TitleDisplay}' is required.", TitleDisplay); TitleLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString()); ForeignKeyProperties = _imagesService.GetForeignKeyPropertiesToDto(image).ToList(); ViewData["ImgId"] = id; ImageId = id; Vm = new UpdateImageViewModel { Title = image.Name, Url = image.Url }; return(Page()); }
public async Task <IActionResult> OnGetAsync() { PageTitle = await TranslationsService.TranslateAsync("Webpages"); TxtAddWebpage = await TranslationsService.TranslateAsync("Add webpage"); TitleDisplay = await TranslationsService.TranslateAsync("title"); NameDisplay = await TranslationsService.TranslateAsync("name"); TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op"); PageNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay); PageNameLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString()); PageTitleLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString()); Pages = await Service.GetAll().OrderBy(p => p.Name).Select(p => new WebpagesViewModel { Id = p.Id, PageName = $"{p.Name.SubstringMaxLengthOrGivenLength(0, 20)}", DateTimeCreated = $"{p.DateTimeCreated.Value.ToShortDateString()} - ({p.DateTimeCreated.Value.ToShortTimeString()})" }).ToListAsync(); return(Page()); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInService.PasswordSignInAsync(Input.Username, Input.Password, Input.RememberMe, lockoutOnFailure : true); if (result.Succeeded) { return(LocalRedirect(returnUrl)); } if (result.RequiresTwoFactor) { return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, Input.RememberMe })); } if (result.IsLockedOut) { return(RedirectToPage("./Lockout")); } else { ModelState.AddModelError(string.Empty, await TranslationsService.TranslateAsync("Ongeldige login poging.")); return(Page()); } }
public async Task <IActionResult> OnGetAsync(string id) { var page = await _webpagesService.FindByIdAsync(id); if (page == null) { return(NotFound()); } TitleDisplay = await TranslationsService.TranslateAsync("title"); NameDisplay = await TranslationsService.TranslateAsync("name"); TxtSeeArticles = await TranslationsService.TranslateAsync("Bekijk artikels"); TxtSeeLinks = await TranslationsService.TranslateAsync("Bekijk links"); PageTitle = await TranslationsService.TranslateAsync("Webpagina bijwerken"); PageTitleLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", TitleDisplay, 4.ToString(), 30.ToString()); ViewData["PageId"] = page.Id; Vm = new WebPageViewModel { Id = page.Id, Name = page.Name, Title = page?.Title }; return(Page()); }
public async Task <IActionResult> OnGet(string returnUrl = null) { if (!_options.Pages.IsRegisteringEnabled) { return(NotFound("Deze pagina is niet beschikbaar.")); } Input = new InputModel { Languages = new List <PickedLanguageDto> { new PickedLanguageDto { ShortLanguage = "NL", LongLanguage = "Nederlands" }, new PickedLanguageDto { ShortLanguage = "EN", LongLanguage = "English" }, new PickedLanguageDto { ShortLanguage = "FR", LongLanguage = "Français" }, new PickedLanguageDto { ShortLanguage = "DE", LongLanguage = "Deutsch" }, } }; TxtSelectLanguage = await TranslationsService.TranslateAsync("Select a language."); ExternalLogins = (await _signInService.GetExternalAuthenticationSchemesAsync()).ToList(); ReturnUrl = returnUrl; IsAuthenticationViaExternalServicesEnabled = _options.User.CanUseExternalAuthenticationServices; return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid id) { var article = await Service.GetAll().Include(a => a.Webpage).FirstOrDefaultAsync(a => a.Id.Equals(id)); if (article == null) { return(NotFound()); } PageTitle = await TranslationsService.TranslateAsync("Artikel bijwerken"); ArticleId = id; Name = article?.Name; MarkdownText = article?.MarkdownText; ViewData["BaseArticleId"] = id; ViewData["ArticleId"] = article.Id; ReturnPage = "/Articles/Index"; if (article.Webpage != null) { ViewData["PageId"] = article.Webpage.Id; PageId = article.Webpage.Id; ReturnPage = "/WebPage/Articles/Index"; } ForeignKeys = Service.GetForeignKeyPropertiesToDto(article).ToList(); return(Page()); }
public async Task <IActionResult> OnGetAsync() { var images = await _imagesService.ListAllAsync(); if (images == null) { return(NotFound()); } PageTitle = await TranslationsService.TranslateAsync("images"); TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op"); TitleDisplay = await TranslationsService.TranslateAsync("title"); Images = images.OrderBy(i => i.Name).Select(i => new ImageDto { Id = i.Id, Url = i.Url, Name = $"{i.Name.SubstringMaxLengthOrGivenLength(0, 20)}", DateTimeCreated = $"{i.DateTimeCreated.Value.ToShortDateString()} - ({i.DateTimeCreated.Value.ToShortTimeString()})" }).ToList(); return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid id) { var link = await _linksService.GetAll().Include(l => l.Webpage).FirstOrDefaultAsync(l => l.Id == id); if (link == null) { return(NotFound()); } ViewData["LinkId"] = link.Id; ViewData["PageId"] = link.Webpage.Id; NameDisplay = await TranslationsService.TranslateAsync("name"); PageTitle = await TranslationsService.TranslateAsync("Update link"); LinkNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay); LinkNameLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString()); LinkUrlRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field 'Url' must contain a minimum of {4} and a maximum of {200} characters.", "Url", 4.ToString(), 200.ToString()); Vm = new LinkViewModel { LinkId = link.Id.ToString(), PageId = link.Webpage.Id, Name = link?.Name, Url = link.Url }; return(Page()); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); ExternalLogins = (await _signInService.GetExternalAuthenticationSchemesAsync()).ToList(); var result = await _userService.CreateAsync(Input.Username, Input.Email, Input.Password, Input.ProfileImage, Input?.Language); if (result.Successfull) { var userId = await _userService.GetUserIdAsync(result.Entity); var roleResult = await _userService.AddToRoleAsync(result.Entity, RoleContstants.RegularUser); if (!roleResult.Succeeded) { foreach (var error in roleResult.Errors) { _logger.LogError(error.Description); } } var code = await _userService.GenerateEmailConfirmationTokenAsync(result.Entity); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId, code, returnUrl }, protocol: Request.Scheme); var sendMailResult = await _sendMailService.SendEmailAsync(Input.Username, Input.Email, $"{await TranslationsService.TranslateAsync("Confirm your email")}", $"{await TranslationsService.TranslateAsync("Klik")} <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>{await TranslationsService.TranslateAsync("hier")}</a> {await TranslationsService.TranslateAsync("pour confirmer votre compte.")}"); if (!sendMailResult.Success) { _logger.LogError($"Gebruiker werd succesvol geregistreerd maar kan zijn e-mail niet bevestigen want {sendMailResult.Message}."); } if (_userService.IdentityOptions().SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl })); } else { await _signInService.SignInAsync(result.Entity, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Message); } return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid?pageId = null) { if (pageId != null) { PageId = pageId; ViewData["PageId"] = PageId; AddArticleUrl = "/WebPage/Articles/Add"; UpdateArticleUrl = "/WebPage/Articles/Update"; var page = await _webPagesService.FindByIdAllIncludedAsync(pageId); if (page == null) { return(NotFound()); } Vm = new ArticlesViewModel { Articles = page.Articles.OrderBy(a => a.Name).Select(a => new ArticleDto { Id = a.Id, Name = a.Name, DateTimeCreated = $"{a.DateTimeCreated?.ToShortDateString()} - ({a.DateTimeCreated?.ToShortTimeString()})" }).ToList() }; } else { AddArticleUrl = "/Articles/Add"; UpdateArticleUrl = "/Article/Index"; var articles = await Service.GetAll().Include(a => a.Webpage) .Include(a => a.Images) .ToListAsync(); Vm = new ArticlesViewModel { Articles = articles.OrderBy(a => a.Name).Select(a => new ArticleDto { Id = a.Id, Name = a.Name, DateTimeCreated = $"{a.DateTimeCreated?.ToShortDateString()} - ({a.DateTimeCreated?.ToShortTimeString()})" }).ToList() }; } PageTitle = await TranslationsService.TranslateAsync("Artikels"); TxtName = await TranslationsService.TranslateAsync("Name"); TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op"); return(Page()); }
public async override Task <JsonResult> AnonymousObjectWithSortedEntitiesAsync(List <Webpage> sortedEntities, string pageId = null) { await Task.Delay(0); return(new JsonResult(new { Entities = sortedEntities.Select(e => CreateDto(e)), TxtUpdate = await TranslationsService.TranslateAsync("Details"), TxtDelete = await TranslationsService.TranslateAsync("Delete"), UpdateUrl = "WebPage", DeleteReturnPage = "WebPages", WebpageId = string.IsNullOrEmpty(pageId) ? "" : pageId })); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); var result = await _signInService.PasswordSignInAsync(Input.Username, Input.Password, Input.RememberMe, lockoutOnFailure : true); if (result.Succeeded) { return(LocalRedirect(returnUrl)); } ModelState.AddModelError(string.Empty, await TranslationsService.TranslateAsync("Ongeldige login poging.")); return(await OnGetAsync()); }
public async Task <ActionResult> OnGetAsync() { Vm = new IndexViewModel { UsersFound = new List <UserDto>() }; PageTitle = await TranslationsService.TranslateAsync("Gebruikers"); TxtUserName = await TranslationsService.TranslateAsync("username"); TxtRequiredUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtUserName}' is required.", TxtUserName); TxtLengthUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TxtUserName}' must contain a minimum of {1} and a maximum of {100} characters.", TxtUserName, 1.ToString(), 100.ToString()); return(Page()); }
public async Task <IActionResult> OnGetAsync() { PageTitle = await TranslationsService.TranslateAsync("Gebruikers"); TxtUserName = await TranslationsService.TranslateAsync("Username"); TxtEmail = await TranslationsService.TranslateAsync("Email"); TxtLanguage = await TranslationsService.TranslateAsync("Language"); TxtPassword = await TranslationsService.TranslateAsync("Password"); TxtConfirmPassword = await TranslationsService.TranslateAsync("Confirm Password"); TxtProfilePicture = await TranslationsService.TranslateAsync("Profile picture"); TxtSelectLanguage = await TranslationsService.TranslateAsync("Select a language."); TxtClickToAddProfPic = await TranslationsService.TranslateAsync("Click here to add a profile picture."); TxtRequiredUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtUserName}' is required.", TxtUserName); TxtRequiredEmail = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtEmail}' is required.", TxtEmail); TxtRequiredPassword = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TxtPassword}' is required.", TxtPassword); TxtLengthUserName = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TxtUserName}' must contain a minimum of {4} and a maximum of {50} characters.", TxtUserName, 4.ToString(), 50.ToString()); TxtCompareError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.CompareFields, $"The field '{TxtConfirmPassword}' and the field '{TxtPassword}' do not match.", TxtConfirmPassword, TxtPassword); Input = new InputModel { Languages = new List <PickedLanguageDto> { new PickedLanguageDto { ShortLanguage = "NL", LongLanguage = "Nederlands" }, new PickedLanguageDto { ShortLanguage = "EN", LongLanguage = "English" }, new PickedLanguageDto { ShortLanguage = "FR", LongLanguage = "Français" }, new PickedLanguageDto { ShortLanguage = "DE", LongLanguage = "Deutsch" }, } }; return(Page()); }
public async Task <IActionResult> OnGetAsync() { ForeignKeyPropertyNames = _imagesService.GetForeignKeyProperties() .Select(fk => fk.Name).ToList(); PageTitle = await TranslationsService.TranslateAsync("Create Image"); TitleDisplay = await TranslationsService.TranslateAsync("title"); ImageDisplay = await TranslationsService.TranslateAsync("image"); TitleRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{TitleDisplay}' is required.", TitleDisplay); TitleLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{TitleDisplay}' must contain a minimum of {2} and a maximum of {30} characters.", TitleDisplay, 2.ToString(), 30.ToString()); FileRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{ImageDisplay}' is required.", ImageDisplay); return(Page()); }
public async Task <IActionResult> OnGetAsync() { TxtGettingStarted = await TranslationsService.TranslateAsync("Getting started"); TxtGettingStartedCreateEntities = $"{TxtGettingStarted}.. ({BtnCreateValue})"; TxtGettingStartedReadEntitiesPartOne = $"{TxtGettingStarted}.. ({await TranslationsService.TranslateAsync("Read")}) {await TranslationsService.TranslateAsync("part one")}."; TxtGettingStartedReadEntitiesPartTwo = $"{TxtGettingStarted}.. ({await TranslationsService.TranslateAsync("Read")}) {await TranslationsService.TranslateAsync("part two")}."; TxtGettingStartedUpdateEntities = $"{TxtGettingStarted}.. ({BtnUpdateValue})"; TxtGettingStartedDeleteEntities = $"{TxtGettingStarted}.. ({BtnDeleteValue})"; TxtCreateArticles = await TranslationsService.TranslateAsync("Create articles"); TxtCreateWebpages = await TranslationsService.TranslateAsync("Create webpages"); TxtCreateLinks = await TranslationsService.TranslateAsync("Create links"); return(Page()); }
public async Task <IActionResult> OnPostAsync() { var user = await _userService.FindByEmailAsync(Input.Email); if (user == null) { _logger.LogInformation("User not found", null); // Don't reveal that the user does not exist or is not confirmed return(RedirectToPage("./ForgotPasswordConfirmation")); } if (!(await _userService.IsEmailConfirmedAsync(user))) { _logger.LogInformation("user exists, confirm email is sent but user has not yet confirmed so cannot reset password.", null); return(RedirectToPage("./ForgotPasswordConfirmation")); } // For more information on how to enable account confirmation and password reset please // visit https://go.microsoft.com/fwlink/?LinkID=532713 var code = await _userService.GeneratePasswordResetTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ResetPassword", pageHandler: null, values: new { area = "Identity", code }, protocol: Request.Scheme); SendEmailResult sendMailRslt = await _sendEmailService.SendEmailAsync( user.UserName, Input.Email, $"{await TranslationsService.TranslateAsync("Reset password")}", $"{await TranslationsService.TranslateAsync("Klik")} <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>{await TranslationsService.TranslateAsync("hier")}</a> {await TranslationsService.TranslateAsync("om uw wachtwoord te resetten.")}"); if (!sendMailRslt.Success) { _logger.LogWarning(sendMailRslt.Message, null); } return(RedirectToPage("./ForgotPasswordConfirmation")); }
public async Task <IActionResult> OnGetAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); PageTitle = await TranslationsService.TranslateAsync("inloggen"); TxtUserName = await TranslationsService.TranslateAsync("username"); TxtPassword = await TranslationsService.TranslateAsync("password"); TxtRememberMe = await TranslationsService.TranslateAsync("Remember me"); TxtRequiredPassword = TranslationsService.TranslateRequiredError(TxtPassword); TxtRequiredUserName = TranslationsService.TranslateRequiredError(TxtUserName); ReturnUrl = returnUrl; return(Page()); }
public async Task <IActionResult> OnGetAsync(string table) { var entities = await EntitiesService.ListAllToDtoAsync(table); if (entities == null) { return(NotFound()); } ViewData["TableName"] = table; Entities = entities.ToList(); TableName = table; TxtName = await TranslationsService.TranslateAsync("Name"); TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op"); EntType = EntitiesService.FindEntityTypeByTableName(table); InheritsFromKerykeionBaseClass = EntitiesService.InheritsFromKeryKeionBaseClass(EntType); return(Page()); }
public virtual async Task <IActionResult> OnGetAsync(Guid pageId) { var page = await _webPagesService.FindByIdAllIncludedAsync(pageId); if (page == null) { return(NotFound()); } PageTitle = await TranslationsService.TranslateAsync("Links"); TxtAddLink = await TranslationsService.TranslateAsync("Add Link"); NameDisplay = await TranslationsService.TranslateAsync("name"); LinkNameRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.RequiredField, $"The field '{NameDisplay}' is required.", NameDisplay); LinkNameLengthError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field '{NameDisplay}' must contain a minimum of {4} and a maximum of {30} characters.", NameDisplay, 4.ToString(), 30.ToString()); LinkUrlRequiredError = TranslationsService.TranslateErrorByDescriber(ErrorDescriberConstants.StringLength, $"The field 'Url' must contain a minimum of {4} and a maximum of {200} characters.", "Url", 4.ToString(), 200.ToString()); TxtAddedOn = await TranslationsService.TranslateAsync("Toegevoegd op"); ViewData["PageId"] = page.Id; Vm = new LinksViewModel { PageId = page.Id }; if (page.Links.Count > 0) { Vm.Links = page.Links.OrderBy(l => l.UniqueNameIdentifier).Select(l => new LinkDto { Id = l.Id, Name = l?.Name, Url = l?.Url, DateTimeCreated = $"{l.DateTimeCreated?.ToShortDateString()} - ({l.DateTimeCreated?.ToShortTimeString()})" }).ToList(); } return(Page()); }
public async Task <IActionResult> OnGetAsync(Guid?pageId = null) { if (pageId != null) { PageId = pageId; ViewData["PageId"] = pageId; ReturnToArticlesUrl = "/WebPage/Articles/Index"; } else { ReturnToArticlesUrl = "/Articles/Index"; Vm = new ArticleForeignKeysVm { ForeignKeyPropertyNames = Service.GetForeignKeyProperties() .Select(fk => fk.Name).ToList() }; } PageTitle = await TranslationsService.TranslateAsync("Artikel toevoegen"); return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var user = await _userService.FindByEmailAsync(Input.Email); if (user == null) { return(Page()); } var userId = await _userService.GetUserIdAsync(user); var code = await _userService.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId, code }, protocol: Request.Scheme); SendEmailResult result = await _sendMailService.SendEmailAsync( user.UserName, Input.Email, $"{await TranslationsService.TranslateAsync("Confirm your email")}", $"{await TranslationsService.TranslateAsync("Klik")} <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>{await TranslationsService.TranslateAsync("hier")}</a> {await TranslationsService.TranslateAsync("pour confirmer votre compte.")}"); if (!result.Success) { _logger.LogWarning(result.Message, null); } return(RedirectToPage("/Index")); }