daisylong
10/11/2023, 8:08 PMD_Inventor
10/12/2023, 4:29 AM.IsPasswordProtected()
Then there is the PasswordFormPage. It seems that this model has a significant amount of service dependencies. How about you take those dependencies out of the model and precalculate the values they produce in a controller instead? Once all the services are out of the model, all thats left for you is to fill the model with data of your choice.D_Inventor
10/12/2023, 6:54 AMD_Inventor
10/12/2023, 7:11 AMContentFinderByUrl
and see if you can find the content by URL. You could let that base class find the current content for you and check your requirements (is it a password protected page? and Is a password configured?)
If so, you can use the published content model to navigate through your content tree and locate the password page using the .Parent()
, .Ancestor()
, .Children()
and .Descendants()
methods on the IPublishedContent
model that the base class provided.
Check out this page in the documentation for more information about content finders:
https://docs.umbraco.com/umbraco-cms/reference/routing/request-pipeline/icontentfinderdaisylong
10/12/2023, 3:54 PMdaisylong
10/12/2023, 3:55 PMD_Inventor
10/12/2023, 6:20 PMIPublishedContent
model and it creates the PasswordFormPage for you. Inject this factory into your controller and you have your logic nicely isolated, in case you decide at some point that you need a different way to create this model.