pwFoo
Members-
Posts
708 -
Joined
-
Last visited
Everything posted by pwFoo
-
NodeBB could be interesting, but it's NodeJS based. Modern and fast. I prefer a php solution.
-
Thanks LostKobrakai, I moved the complex email validation plugin, ProcessForgotPassword and LoginPersist module integration into the FrontendUser module for testing. If anyone would do some tests... Repo: https://bitbucket.org/pwFoo/frontenduser/overview Doku: https://bitbucket.org/pwFoo/frontenduser/wiki/Documentation Current download for testing: https://bitbucket.org/pwFoo/frontenduser/get/master.zip
-
I use Esotalk in latest dev (bug and security fixes!!!) and it works fine. After Flarum release there will be an upgrade path from Esotalk to Flarum. I used smf (and phpbb) in the past and I'm member of plenty of different forum systems. It's good like phpBB and other well-known software. Responsive themes should be available or you could build your own theme, but Esotalk just fit my needs (clean theme, color changable, mobile friendly) SMF have a simple api which if fine for a simple integration.
-
Flarum beeing built in Laravel and Ember.js. That's why Esotalk will be faster than Flarum. I think it will be an great and modern alternative to smf, phpBB and other well-known forum software in the future.
-
I like the (mobile friendly, responsive) UI and look of Esotalk (minimal maintained! http://esotalk.org/), but it should die with the Flarum release (at the moment dev state, github).
-
First, you needn't read and understand all the source code following here. It's a design question Simple FrontendUser plugins are small code snippets (PW hooks) and could be added to the template. // add a default role during user registration $fu->addHookBefore('save', function($event) { $user = $event->object->attr('userObj'); $user->addRole('superuser'); }); // Fill nickname field with username sanitized as text instead of username $fu->addHookBefore('save', function($event) { $fu = $event->object; $form = $fu->attr('form'); if(!count($form->getErrors())) { $fu->attr('userObj')->nickname = $form->fhValue('username', 'text'); } }); It's to small to build a PW module, isn't it??? But some plugins are more complex like email pre-register validation... function validationCodeField() { $validation = wire('modules')->get('InputfieldText'); $validation->attr('id+name', 'EmailPreValidation'); $validation->placeholder = 'Email validation code'; $validation->skipLabel = 4; $validation->required = 1; return $validation; } $form = $fu->register(array('username', 'email', validationCodeField(), 'password'))->attr('form'); $form->addhookBefore('processInput', function($event) { $form = $event->object; var_dump(wire('input')->post); echo "<hr />"; if (empty(wire('session')->get('registerStep'))) { $form->get('password')->required = false; $form->get('EmailPreValidation')->required = false; } }); $form->addhookAfter('processInput', function($event) { $form = $event->object; $user = $form->get('username'); $email = $form->get('email'); if (!empty(wire('session')->get('registerStep')) && wire('session')->get('registerEmail') !== $form->fhValue('email')) { wire('session')->remove('registerStep'); $form->get('EmailPreValidation')->value = ''; $form->fhSubmitBtn->error('Validation broken by email address mismatch!'); wire('session')->redirect(wire('page')->url, false); } elseif (empty(wire('session')->get('registerStep')) && !count($user->getErrors()) && !count($email->getErrors())) { echo "SET Session values!<br />"; wire('session')->set('registerToken', md5(uniqid(mt_rand(), true))); wire('session')->set('registerUsername', $form->fhValue('username')); wire('session')->set('registerEmail', $form->fhValue('email')); wire('session')->set('registerStep', 1); // Send validation code email wireMail($form->fhValue('email'), null, 'Email address pre-validation', "Validation token: " . wire('session')->get('registerToken')); } elseif (!count($user->getErrors()) && !count($email->getErrors())) { if ($form->fhValue('EmailPreValidation') != wire('session')->get('registerToken')) { $form->get('EmailPreValidation')->error('Email validation code NOT match!'); } } }); $form->addhookBefore('render', function($event) { $form = $event->object; if ($form->fhState === null) { wire('session')->remove('registerStep'); } elseif (wire('session')->get('registerStep') === 1) { $form->fhSubmitBtn->getErrors(true); } if (empty(wire('session')->get('registerStep'))) { $form->remove($form->get('password')); $form->get('EmailPreValidation')->attr('disabled', true); $form->fhSubmitBtn->value = 'Send email validation code'; echo "RESET Session values!<br />"; wire('session')->remove('registerToken'); wire('session')->remove('registerUsername'); wire('session')->remove('registerEmail'); } echo "RegisterStep: " . wire('session')->get('registerStep') . "<br />"; echo "Username: " . wire('session')->get('registerUsername') . "<br />"; echo "Email: " . wire('session')->get('registerEmail') . " == " . $form->fhValue('email') . "<br />"; echo "Token: " . wire('session')->get('registerToken') . "<br />"; }); How to handle such complex plugins? As template "snippet" / include code or as a extension PW module? Should each plugin be a PW module or shouldn't we create endless quantity of small modules?
-
Updated testing branch of FrontendUser module (login / logout + register) https://bitbucket.org/pwFoo/frontenduser/src/1d97e2179784e60c7adad58e35152562291ec8ae/?at=testing
-
Updated testing branch of FrontendUser module (login / logout + register) https://bitbucket.org/pwFoo/frontenduser/src/1d97e2179784e60c7adad58e35152562291ec8ae/?at=testing
-
I used a hidden storage page as workaround. It's also used to build the FormHelperExtra module (proof of concept, first draft after separating additional features from FormHelper module). Hidden page is created / deleted during module install / uninstall. If the page isn't saved files are added to the storage page object. During page save you can move the files from storage to the new page (add() & unlink()). Should work fine... You can use the experimental code as example. FormHelperExtra module should work, but code will changed / optimized in the future.
-
I try to build a basic login, logout and register module which could be extended by plugins (PW hooks), but have to be optimized and maybe merged into one module before it will be released... Basic register module (check if username / email already exists) https://bitbucket.org/pwFoo/frontenduser/src/ac39eb355e49016efd2e5f8595bfc1917ebea80f?at=master Plugin (PW hooks) examples like email pre-validation, add default registration role without hack the module itself. https://bitbucket.org/pwFoo/frontenduser/wiki/FrontendUserRegister It's work in progress. So some things may change (thinking about to merge login and register module...). Form handling is done by FormHelper (simplify value sanitizing, take care about form creation, submit button, processing, field errors and prepare file uploads). You can take a look at username / email validation (checks if already exists). It's done as a Inputfield hook.
-
Would be great to have some more up to date documentation. Apigen and cheatsheet seems to be outdated?
-
Thanks. I thinking about a merged module FrontendUser with login, logout and register functionality... The main diff are the form fields (username, password vs. username, password + validation, email) / callback hooks (check form errors vs. already in use) and some lines of code. Each functionality could need only one custom method (login / auth user, logout user, save temp user). Shared code is form handling (minimal code because based on FormHelper module). So a merged module shouldn't have a relevant overhead.
-
As example. I write two modules FrontendUserLogin and FrontendUserRegister. Both modules share code by an abstract php class (form handling, style / script loading, ...). I bundled the login and register module with the abstract class to FrontendUser. So I have two modules with module version. At the moment there is no bundle / repo version. If I move the module info to the abstract class both modules will share one version... If I separating the modules I have to duplicate the shared base source code. Another way could be to bring both modules together.
-
I write a module which is separated by module functionality into two modules. Both share code (abstract php class) to prevent duplicated code. How should I set version number(s)? Own version for each file? But I need a "bundle version" (for example module version added to PW module repo)? Should I use file and module versions? Or only a "bundle" version?
-
FrontendUserLogin module deletion requested, because it's an old and deprecated version. Last posts here reference to a redesigned and not compatible new module / branch.
-
FrontendUserRegistration module deletion requested, because it's an old and deprecated version. Last posts here reference to a redesigned and not compatible new module / branch.
-
Solved by a hook to remove required and than the hole field from the form. It was the easiest way... Thanks Adrian.
-
New testing FrontendUser module could be replace FrontendUserRegister and FrontendUserLogin module. It requires FormHelper (0.7.1+) Repo: https://bitbucket.org/pwFoo/frontenduser/src FrontendUserLogin Details: https://processwire.com/talk/topic/8001-frontenduserlogin/?p=92538 Simple / basic login / logout module error handling default and custom styles / scrips extendable with plugins (PW hooks!), examples: login with email address instead of username, PersistLogin and ProcessForgotPassword integration FrontendUserRegister Simple / basic user register module (username, email, password) error handling default and custom styles / scrips extendable with plugins (PW hooks!), examples: further down FrontendUserRegister (simple usage) Only use basic fields and features. $fu = $modules->get('FrontendUserRegister'); $content = $fu->render($redirectAfterRegister); AddRole plugin Really simple plugin / hook to add a default role before user will be saved $fu = $modules->get('FrontendUserRegister'); $form = $fu->form(); $fu->addHookBefore('saveUser', function($event) { $user = $event->object->attr('userObj'); $user->addRole('superuser'); }); $content = $fu->validate()->process()->renderForm(); Display name plugin Username will be sanitized as username, but you could add a field "nickname" to the user template with username value sanitized as text instead of username. // Dispay- / Nickname $fu->addHookBefore('saveUser', function($event) { $fu = $event->object; $form = $fu->attr('form'); if(!count($form->getErrors())) { $fu->attr('userObj')->nickname = $form->fhValue('username', 'text'); } }); Pre-validate email address plugin A more complex plugin to add a additional register step. It removes the password field and adds an validation code input field. After submit username and email address you'll get an email with a validation code. Second step enter the code and a password to register a PW user. The code includes some debugging information / output because it needs more testing... $fu = $modules->get('FrontendUserRegister'); function validationCodeField() { $validation = wire('modules')->get('InputfieldText'); $validation->attr('id+name', 'EmailPreValidation'); $validation->placeholder = 'Email validation code'; $validation->skipLabel = 4; $validation->required = 1; return $validation; } // modified / extended register form $form = $fu->form(array('username', 'email', validationCodeField(), 'password'))->attr('form'); $form->addhookBefore('processInput', function($event) { $form = $event->object; var_dump(wire('input')->post); echo "<hr />"; if (empty(wire('session')->get('registerStep'))) { $form->get('password')->required = false; $form->get('EmailPreValidation')->required = false; } }); $form->addhookAfter('processInput', function($event) { $form = $event->object; $user = $form->get('username'); $email = $form->get('email'); if (!empty(wire('session')->get('registerStep')) && wire('session')->get('registerEmail') !== $form->fhValue('email')) { wire('session')->remove('registerStep'); $form->get('EmailPreValidation')->value = ''; $form->fhSubmitBtn->error('Validation broken by email address mismatch!'); wire('session')->redirect(wire('page')->url, false); } elseif (empty(wire('session')->get('registerStep')) && !count($user->getErrors()) && !count($email->getErrors())) { echo "SET Session values!<br />"; wire('session')->set('registerToken', md5(uniqid(mt_rand(), true))); wire('session')->set('registerUsername', $form->fhValue('username')); wire('session')->set('registerEmail', $form->fhValue('email')); wire('session')->set('registerStep', 1); // Send validation code email wireMail($form->fhValue('email'), null, 'Email address pre-validation', "Validation token: " . wire('session')->get('registerToken')); } elseif (!count($user->getErrors()) && !count($email->getErrors())) { if ($form->fhValue('EmailPreValidation') != wire('session')->get('registerToken')) { $form->get('EmailPreValidation')->error('Email validation code NOT match!'); } } }); $form->addhookBefore('render', function($event) { $form = $event->object; if ($form->fhState === null) { wire('session')->remove('registerStep'); } elseif (wire('session')->get('registerStep') === 1) { $form->fhSubmitBtn->getErrors(true); } if (empty(wire('session')->get('registerStep'))) { $form->remove($form->get('password')); $form->get('EmailPreValidation')->attr('disabled', true); $form->fhSubmitBtn->value = 'Send email validation code'; echo "RESET Session values!<br />"; wire('session')->remove('registerToken'); wire('session')->remove('registerUsername'); wire('session')->remove('registerEmail'); } echo "RegisterStep: " . wire('session')->get('registerStep') . "<br />"; echo "Username: " . wire('session')->get('registerUsername') . "<br />"; echo "Email: " . wire('session')->get('registerEmail') . " == " . $form->fhValue('email') . "<br />"; echo "Token: " . wire('session')->get('registerToken') . "<br />"; }); $content = $fu->validate()->process()->renderForm();
-
Hi Adrian, thank you for your reply, but that is not what I need. If you set InputfieldPassword to hidden or disabled only the password field named password will be affected, but there is a second field (confirmation!) named _password. Here you can see the markup generated by InputfieldPassword (only input elements). <p><input id="password" class=" required" name="password" type="password" size="50" maxlength="256" disabled="1" /></p> <p><input type='password' size='50' name='_password' value='' /> <span class='detail'>(confirm)</span></p> Haven't found a way to disable both fields via field settings.
-
How to disable the InputfieldPassword input fields? $pass = $form->get('password'); $pass->attr('disabled', true); With the example above the password field is disabled, but the "confirm" input field is enabled.
-
Here is a FrontendUserLogin screenshot with additional fields (PersistLogin, ProcessForgotPassword integration) and a basic style (removed list style), Form fields without label and placeholder instead. Default css / js can be added inside the module directory. Custom styles will be loaded from templates/FrontendUserLogin/FrontendUserLogin.<css|js>. FormHelper dependency could be replaced, but in version 0.7+ FormHelper isn't that big and no need to copy & paste form handling to each module with forms or file upload (FrontendUserLogin, FrontendUserRegister, contact form, ...).
-
Redesigned FormHelper 0.7.1 is available via PW module repo. You can download the FrontendUserLogin and FrontendUserRegister modules bundled as FrontendUser here (Repo). Both modules provide base features. Extendable with examples you see above.
-
Updated to work with FormHelper 0.7.1 / FormHelperExtra after redesign. FCM is NOT ready to use!!! No value sanitizing without additional code (set a sanitizer to each field.
-
New version 0.7.1 and added the FormHelperExtra (proof of concept!) module to handle removed features.