Check Password While User Account Creation

alt=
@dobmat
10 years ago
93 posts
Hi

I want Jamroom to check password to be having specific characters while user account creation. I'm new to PHP and Jamroom. But from what I have learnt from documentation is that include.php in module jrUser is to be modified. Am I on the right path. Please suggest how I can go about for it.

Thanks.
updated by @dobmat: 07/09/16 09:21:02AM
brian
@brian
10 years ago
10,148 posts
You definitely don't want to modify the jrUser module - there's no need to. Instead you want to create your own custom small module that has an event listener inside that watches for signups and can check the incoming password for whatever rules you would like. Something like this:

1) Create a new directory in your modules directory called "pwCheck" or whatever you want to call it.

2) create a new file inside that directory called "include.php" with the following inside:

<?php

// Meta data about our module
function pwCheck_meta(){
    $_tmp = array(
        'name'        => 'Password Checker',
        'url'         => 'pwcheck',
        'version'     => '1.0.0',
        'developer'   => 'Your Name',
        'description' => 'Checks users passwords on signup',
        'category'    => 'users'
    );
    return $_tmp;
}

// Init function
function pwCheck_init(){
    jrCore_register_event_listener('jrCore', 'form_validate_exit', 'pwCheck_listener');
    return true;
}

// Validate password field after core has validated other fields
function pwCheck_listener($_data, $_user, $_conf, $_args, $event)
{ global $_post; if ($_post['module'] == 'jrUser' && $_post['option'] == 'signup_save') { // We have a new user creating an account - check password if ($_post['user_passwd1'] != 'abcdefg') { jrCore_set_form_notice('error', 'Your password is not abcdefg!'); jrCore_form_field_hilight('user_passwd1'); jrCore_form_field_hilight('user_passwd2'); jrCore_form_result(); } } return $_data; } ?>

Just adjust this part:

if ($_post['user_passwd1'] != 'abcdefg') {

to suit your needs.

3) You can add a small “icon.png” file in the same directory if you’d like an icon in ACP.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/18/14 06:26:47AM
alt=
@dobmat
10 years ago
93 posts
It seems module is not picking up the event. I have enabled the module through ACP. Am I missing something here?

Thanks.
brian
@brian
10 years ago
10,148 posts
I just did it here on my local install and I am not seeing any issues - see attached screenshot.

As long as the module is active, it should work. Double check you didn't mistype anything.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/18/14 10:42:35AM
alt=
@dobmat
10 years ago
93 posts
Its working, there was something wrong with my logic in if statement. I'm guessing I need to modify some template file if want to change fields in say login page, as I have changed header and footers from template. Please advice.

Thanks.
michael
@michael
10 years ago
7,748 posts
Changing fields is usually the job of the "Form Designer". The exception to that rule is the login form.

You can add the login form to any page via the code here:

"Howto add the user login form to any page"
https://www.jamroom.net/the-jamroom-network/documentation/howto/603/howto-add-the-user-login-form-to-any-page

For standard forms, you can alter with the Form Designer:

"Using the Form Designer"
https://www.jamroom.net/the-jamroom-network/documentation/getting-started/1275/using-the-form-designer
updated by @michael: 12/29/14 09:23:55AM
alt=
@dobmat
10 years ago
93 posts
Thanks for the inputs. If I want to change names of textboxes and button do I need to change that in the lang file? I made some changes in jrUser's lang file, but it seeems it is not reflected on the pages.

Thanks.
brian
@brian
10 years ago
10,148 posts
dobmat:
Thanks for the inputs. If I want to change names of textboxes and button do I need to change that in the lang file? I made some changes in jrUser's lang file, but it seeems it is not reflected on the pages.

Thanks.

No - you don't modify the file - that's why in all capitals at the top of the file it says:

Quote:
// DO NOT EDIT THIS FILE. THIS FILE IS ONLY LOADED DURING INSTALLATION!
// ANY CHANGES TO LANGUAGE STRINGS SHOULD BE DONE IN THE CONTROL PANEL!

You need to go to the ACP -> User Accounts -> Language tab and make your modifications there. Then you need to reset caches to see your changes.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 03/20/14 07:52:10AM
alt=
@dobmat
10 years ago
93 posts
Oh. My mistake, I didn't notice it. Thanks a lot for the help.

Tags