Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Button Generate password and chackbox show/hide password #1249

Open
wants to merge 113 commits into
base: master
Choose a base branch
from

Conversation

manieqq
Copy link

@manieqq manieqq commented Oct 10, 2016

Hello, I have a proposal
To add a User Module button "Generete password" and show / hide password checkbox

We need to create a file in generate_password.js location: bonfire / modules / users / assets / js

file generate_password.js

function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
return pass;
}

function generate() {
myform.password.value = randomPassword(myform.length.value);
myform.pass_confirm.value = myform.password.value;
}

(function() {

var PasswordToggler = function( element, field ) {
this.element = element;
this.field = field;

  this.toggle();  

};

PasswordToggler.prototype = {
toggle: function() {
var self = this;
self.element.addEventListener( "change", function() {
if( self.element.checked ) {
self.field.setAttribute( "type", "text" );
} else {
self.field.setAttribute( "type", "password" );
}
}, false);
}
};

document.addEventListener( "DOMContentLoaded", function() {
var checkbox = document.querySelector( "#show-hide" ),
password = document.querySelector( "#password" ),
form = document.querySelector( "#myform" );

      form.addEventListener( "submit", function( e ) {
          e.preventDefault();
      }, false);

      var toggler = new PasswordToggler( checkbox, password );

});

})();

then the controller: / bonfire / modules / users / controllers add code

Assets :: add_module_js ( 'users', 'generate_password.js');

and the last step in the files:
/bonfire/modules/users/views/settings/user_form.php

change:
echo form_open ($ this-> uri-> uri_string (), array ( 'class' => 'form-horizontal', 'autocomplete' => 'off'));
fix:
echo form_open ($ this-> uri-> uri_string (), array ( 'id' => 'myform', 'class' => 'form-horizontal', 'autocomplete' => 'off'));

and add line:

<input type="hidden" name="length" value="<? echo settings_item('auth.password_min_length'); ?>">

/bonfire/modules/users/views/user_fields.php

add code:

& Nbsp; <input type = "button" class = "button" value = "Generate" onClick = "generate ();" tabindex = "2">
        <Label for = "show-hide"> <input type = "checkbox" id = "show-hide" name = "show-hide" value = "" /> Show password </ label>
<Span class = "help-inline"> <? Php echo form_error ( 'password'); ?> </ Span>

change:

<Div class = "control-group <? Php echo form_error ( 'password')? $ ErrorClass: '';?>">
    <Label class = "control-label <? Php echo $ registerClass;?>" For = "password"> <? Php echo lang ( 'bf_password'); ?> </ Label>
    <Div class = "controls">
        <Input class = "<? Php echo $ controlClass;?>" Type = "password" id = "password" name = "password" value = "" />
<Span class = "help-inline"> <? Php echo form_error ( 'password'); ?> </ Span>
        <P class = "help-block"> <? Php echo isset ($ password_hints)? $ Password_hints: ''; ?> </ P>
    </ Div>
</ Div>

fix:

<Div class = "control-group <? Php echo form_error ( 'password')? $ ErrorClass: '';?>">
    <Label class = "control-label <? Php echo $ registerClass;?>" For = "password"> <? Php echo lang ( 'bf_password'); ?> </ Label>
    <Div class = "controls">
        <Input class = "<? Php echo $ controlClass;?>" Type = "password" id = "password" name = "password" value = "" />
& Nbsp; <input type = "button" class = "button" value = "Generate" onClick = "generate ();" tabindex = "2">
        <Label for = "show-hide"> <input type = "checkbox" id = "show-hide" name = "show-hide" value = "" /> Show password </ label>
<Span class = "help-inline"> <? Php echo form_error ( 'password'); ?> </ Span>
        <P class = "help-block"> <? Php echo isset ($ password_hints)? $ Password_hints: ''; ?> </ P>
    </ Div>
</ Div>

Forum user pslorick reported that functions defined in MY_*_helper could
not override those defined in BF_*_helper:
http://forums.cibonfire.com/discussion/2911/can-i-override-bf-form-helper
- Many of the BF_Loader methods were only needed to work around
differences between the loaders for CI2 and CI3, and have now been
removed
- The Modules library will no longer load controllers which do not have
a ucfirst() filename
* The Migrations library's constructor now loads the file containing the
abstract class via a require_once() call.
* Removed deprecated methods/properties from the Migrations library.
Removed use of `module_file_path()` from `Images` controller, replaced
with `Modules::file_path()`
Removed deprecated properties/methods from docs
use `Assets::setGlobals()` instead
use `CommonMark->convert()` instead
use `Form::prepValue()` instead
use `Template::setSessionUse()`, `Template::setLayout()`, and
`Template::getLayout()` instead
* Use `Modulebuilder->buildFiles()` instead of
`Modulebuilder->build_files()`.
* Use `mkdir()`, passing true as the third parameter, instead of
`Modulebuilder->mkdir_recursive()`.
* In the `builder` module's `Developer` controller, the
`_check_writeable()` method has been removed (replaced with the private
method `checkWritable()`).
Use the equivalent `translate_*` entries, instead.
Use `renderSearchBox()` instead.
Use `Contexts::getContexts()` and `Contexts::setContexts()` instead
* Removed `save_user()` from `Users` controller (replaced with
`saveUser()`)
* Restructured cookie handling in `Auth` library, as well as the `Auth`
library's loading of `Template`/settings libraries and `cookie_helper`
- Replaced with reading the property `router->method`
Removed CI2 compatibility from config files
This was added to App_hooks to provide forward-compatibility for CI2.
- showProfiler() checked for CI2 to determine use of
$this->input->is_cli_request() vs. is_cli()
- deprecated the public method autoload_classes() in favor of protected
method autoloadClasses()
lonnieezell and others added 27 commits January 23, 2017 22:44
- Fix migrate v44
- Fix admin header profile link
the pattern string can not work right in my workspace.
And it can stile work right after remove `<br />` for old version users.
in this helper class, the function ` read_config()` read config files from environment path, but the function `write_config()` not do this, so it can not work good for that who use multiple environments.
I fix this for by following the logic of function `read_config()`.
Update config_file_helper.php
Update deprecated constructor in PHP 7
Update Markdown helpers constructor
Add multi languages support for module description on context menu
Assets: Generate different combined filenames for different included asset files
Added core update + patches
initial basic testing done.
CI3 Updates & Fixes 3.1.6
Added core update + patches
Added Session Lib fix (3.1.10)
initial basic testing done.
CI3 core Updates & Fixes 3.1.9
@OAVHomeAdmin
Copy link

Have all these commits been integrated already?

Reconix and others added 2 commits December 17, 2019 05:33
Fix: bracket for count() argument
Fix: The each() function is deprecated
Fix @font-face parsing missing =
Fix: @Keyframes double quotes
Fix: case - value of url() contains parentheses
remove Whitelist comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.