-
Posts
6,264 -
Joined
-
Last visited
-
Days Won
314
Everything posted by bernhard
-
View a cached page without connecting to PW-database
bernhard replied to eydun's topic in General Support
I don't think it's a good idea to shut down the database completely. ProCache will cache pages for a given amount of time and then try to recreate the cache. I don't think that it will be happy about a dead db connection... Do you want to tell us WHY you want to do that? There's also https://processwire.com/modules/static-wire/ but I've never used it and I don't know if it still works... -
I think you are right for the ->title, but not for the ->url. The url is a property of the page object, not a regular field. So there is no textformatter applied and therefore it should just work like shown in the example. If you have a textformatter applied on the title field, then you'd need a |noescape filter in latte, yes.
-
I'd go with option 4 and use $page->getFormatted('your_image_field') ? That ensures you get the formatted value no matter which state the global OF is in. And you can use the new syntax like $page->getFormatted('your_image_field.first') if you want to ensure that you get a single page image object no matter what the field settings say about the formatted value. That means even if your field settings are changed some time by some person your script will still work.
-
First of all there is $page->of(false) and $pages->of(false). First is singular and sets OF for the single page object, second is plural and sets it globally. Second, even if you have OF=false on a page and you echo a field's content, then you request the string value, which will automatically request the formatted value of your field: Also if you are on the frontend and not in module development there should be OF=true by default.
-
Hey @zx80 welcome to the forum! Glad to hear that! Would be interested in how you found my video (which one btw)? I'm not sure if I understand, but it sounds like you have already found a better approach? When being new to PW there are often situations where you think far too complicated, because you have learned that things work like that or have been done like that. And in PW there is often a much easier and quicker way. Not always of course ? As I didn't really understand what exactly you are trying to do I'm also not sure why you need a console script here? Great! If you still need help or have questions it might help to give more detailed examples. If you are already happy with what you have congrats for your first steps in PW ?
-
It should work just like any other PW api... Does it render empty divs? Does it throw an exception? I'm never using {include ...}, I'm always using {$rockfrontend->render(...)}, but both should work.
-
Define "low cost" ?
-
Hi @Richard Jedlička thx for the update! Sorry for not replying to your request. I wanted to suggest taking the module under my control, but then I thought it might make more sense to create some RockMigrations tweaks instead. But I think your module is really useful and complete as it is (now with the fix ? ) and I guess it will work like this for a long time without any necessary maintenance, so I think there is no real pressure in changing anything. Or do you see that differently?
-
Using halt() within a function in template file
bernhard replied to Ivan Gretsky's topic in API & Templates
I think your question totally depends on how you have built your frontend. When using RockFrontend for example you could hook into RockFrontend::render() and then trigger the halt() before or after any portion of code has been rendered. -
Very interesting blog article that compares twig / blade / latte: https://blog.nette.org/en/quiz-can-you-defend-against-xss-vulnerability
-
I don't think that this is true ? Repeater items are just regular PW pages. They are hidden in the page tree somewhere under the admin page. It should then be possible to create a page reference field with a selector like "parent=123,include=all" Where 123 is the id of the page that holds your repeater items. Not sure if the include=all is necessary, just try it without.
-
Frontend validation regex for username and password?
bernhard replied to bernhard's topic in General Support
Have you had a look at https://github.com/baumrock/PassPhraseJS ? You can simply include the js file and add 3 html attributes and you are done ? Yeah I've had such a misconception in my head initially so I might have communicated that confusingly. -
Frontend validation regex for username and password?
bernhard replied to bernhard's topic in General Support
You see in the screenshot that it's a regular form inputfield, so you can enter whatever password you want ? I just wanted to have a nice little helper to choose from a random generated one. First thought was to just create a random string with a random length, but it's a product targeted for non-tech people and should be as simple to use as possible, so a password like 237u89gdisjv783z9rfre90fuds is for sure not a good option in terms of UX ? But if anyone wants to use such a password (because he/she is using a password manager for example) then that's no problem. No, I don't force the user to use this syntax, so he/she can use whatever he/she wants. I only add a minimum length rule to the password (using RockForms, so all rules apply both on the frontend and on the backend!): $this->addPassword('pass', 'Passwort') ->addRule( $this::MIN_LENGTH, 'Das Passwort muss mindestens %d Zeichen lang sein.', $dev ? 1 : 10 ) ->setRequired('Bitte gib dein gewünschtes Passwort ein.') ->setHtmlAttribute('autocomplete', 'new-password'); And an equal rule to the password confirmation field: $this->addPassword('pass2', 'Passwort bestätigen') ->addRule($this::EQUAL, 'Die Passwörter stimmen nicht überein.', $this['pass']) ->setRequired('Bitte bestätige dein Passwort um Tippfehler zu vermeiden.'); And then the markup for PassPhraseJS: $this->addMarkup("<div class='tm-pass-suggest'>Zufallspasswort verwenden: " . '<a href=# passphrasejs-renew="#pass">-- svg reload icon --</a>' . '<a href=# passphrasejs-copyto="input[type=password]">' . '<span id="pass" passphrasejs></span>' . '--svg copy icon--' . "</a>" . "</div>"); I've done some research on how to sanitize the password on the backend, but it looks like there is no method for it. I've tried setting "foo bar" as password via the API and that works and the user can log in. But I will disallow spaces in my passwords for sure. So I think it's enough to use $sanitizer->text() and then additionally check if the password has a space in it. But I'm not sure yet, so any input is welcome ? -
Frontend validation regex for username and password?
bernhard replied to bernhard's topic in General Support
I think this is already quite impressive! I've updated the tool to support custom separators. This leads to an enormous number of possible combinations even if you only have 4 words in the dictionary, namely over 2 million! -
Of course. And that's the problem sometimes. If you don't know a lot about a problem you simply can't provide a good prompt. For example if you wanted a javascript array with some items and you didn't know what an array is, how would you ever get to that result? I'm on the free account, no idea what version that means. And I'm happy to learn, if you can show me how a good prompt in that example could look like ?
-
Frontend validation regex for username and password?
bernhard replied to bernhard's topic in General Support
Ok, thank you both ? Here are my learnings: I went to the backend user profile to see if the password field has some helpful information I searched the core files for "characters long" wich was found in InputfieldPassword.module $minlength was a variable there, so I thought - as always - this would be configurable by PW I looked into Modules > Core > InputfieldPassword and found no configurable fields *surprise I found this thread and especially this answer by ryan: https://processwire.com/talk/topic/3149-password-complexity-requirements/?do=findComment&comment=31155 Luckily @adrian posted a link to the blog post that shows that everything is configurable now, I was just looking at the wrong spot: https://processwire.com/talk/topic/3149-password-complexity-requirements/?do=findComment&comment=158365 / blog post: https://processwire.com/blog/posts/upgrades-optimizations-pw-3.0.22/#major-enhancements-to-our-password-field Then I took a breath and thought about it as I somewhere read that forcing the user to use numbers might not be the best/most secure option and using a random string instead could be better in terms of UX and also security. Also when creating users in PW via the API the password requirements do not apply - so I can choose whatever syntax/requirements I wanted. So I created created an array of 100 random german words with the help of AI and then played around with that a little. This is the result: https://github.com/baumrock/PassPhraseJS I've also built an interactive calculator to see how many random passwords are possible with your chosen settings: https://baumrock.github.io/PassPhraseJS/example.html What do you guys think? Any suggestions for improvements? I'm already working on making the separators configurable so that will increase the number of possible passwords tremendously. -
I have to say these new AI tools are really impressive, very powerful and more and more useful in my everyday work! I'm working on a small little javascript class to generate random pass phrases. I got an error so I asked chatgpt and copied the whole js file's content: The answer was spot on and it would have taken me a lot longer to find that issue on my own. Actually I learned something new as JS is not my strongest foot and I've had this issues a couple of times before where I was wondering why somethings this.foo() works and sometimes it doesn't. Everything makes sense now ? I'm quite impressed!
-
Frontend validation regex for username and password?
bernhard replied to bernhard's topic in General Support
Hey @kongondo thx I'm already working on something and I'll keep you updated! ? -
Does anybody (maybe @Juergen) know if there is a regex somewhere that I can use to validate user input in a frontend registration form? Of course I will sanitize/validate input on the server as well, but it would save some unnecessary form submissions and server requests ? Thx!