Page 1 of 2

How does user change their own password?

Posted: Tue Nov 27, 2012 3:57 am
by tschutter
How does a non-globeadmin user change their own password?

I am using nubuilder-v2.7.4.11-12.10.24-Build529 on Ubuntu 12.10 browsing with Chromium 22.0.1229.94.

What is the standard way to enable a user to change their own password? Do I have to setup all the bits to enable them access to the Users form, but only for the current user? Is there a recipe for this? Or am I missing something?

Re: How does user change their own password?

Posted: Tue Nov 27, 2012 5:23 am
by admin
tschutter,

There is no facility at this point, you could create your own or make it the admin's job.

http://forums.nubuilder.cloud/viewtopic.p ... 061#p11061

Steven

Re: How does user change their own password?

Posted: Tue Nov 27, 2012 1:50 pm
by johan
tschutter,

You could create a new form with sql

Code: Select all

SELECT * FROM `zzsys_user` WHERE  zzsys_user_id = '#zzsys_user_id#' 
Add In the custom code of the form:

Code: Select all

if('#sus_login_password_was#' != '#sus_login_password#'){
   $s = "update zzsys_user set sus_login_password = md5(CONCAT('nu',sus_login_password)) ";
   $s .= "WHERE zzsys_user_id = '#newID#'";
   nuRunQuery($s);

}
Set 2 textfields on that form sus_name(read only) and sus_login_password

Now the user can update his own password.

Johan

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 2:24 pm
by mlgeek
Johan-

I'm trying to implement this.

Which sub-tab of Custom Code would this go in?
Image

"After Save"?

Has anyone else successfully done this?

Many thanks!

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 4:23 pm
by zazzium
mlgeek,

One option would be to make a form (example for zzsys_variable- It does not matter)
make one text field ..name it password_holder

add After Save:

Code: Select all

$pass = $_POST['password_holder'];
$user = '#zzsys_user_id#';

$sql = "UPDATE zzsys_user SET sus_login_password = '$pass'";
$sql .= " WHERE zzsys_user_id = '$user'";
nuRunQuery($sql);
Make a button and on the Button properties set 'Form To Launch via Browse' the form u made, and set 'Record ID' -1 (impotant).
Give the user access to the button.
Now a user can change his password.

This is a general idea ..u should play around with md5 like johan mentioned, and maybe add a second field just to check that the user are entering the same value twice

zazzium

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 4:47 pm
by mlgeek
Cool. Thanks, Zazzium- much appreciated.

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 7:28 pm
by mlgeek
Solved, I think.

I ended up doing what johan had suggested. It is worth noting, though, that what he suggested was essentially making a copy of the existing USERS form (a set-up form that is not, by default, available to edit in-browser.

In hopes that this is useful to someone else:
  • Created new Form, change_password
    Image

    Code: Select all

    SELECT * FROM zzsys_user
    WHERE zzsys_user_id='#zzsys_user_id#'
  • Created needed fields:
    Image
  • Set sus_login_password_was to never display:
    Image
  • Set sus_name and sus_login_name to read-only on the Text tab for each field.
  • In the form's Custom Code tab, used johan's template in After Save
    Image

    Code: Select all

    if('#sus_login_password_was#' != '#sus_login_password#'){
       $s = "update zzsys_user set sus_login_password = md5(CONCAT('nu',sus_login_password)) ";
       $s .= "WHERE zzsys_user_id = '#newID#'";
       nuRunQuery($s);
    
    }
  • Created index button for "Change Your Password" that launches this new form.
One remaining problem:

I had hoped that the user would be able to skip the Browse/Search screen and go straight to the record edit screen if I specified the Record ID for the button as #zzsys_user_id#, but that doesn't seem to work- it results in an edit screen that shows all fields as blank. I suspect I'm doing something very stupid here, though, and that I'll kick myself when I figure it out.

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 8:44 pm
by zazzium
I had hoped that the user would be able to skip the Browse/Search screen and go straight to the record edit screen
My suggestion is doing exactly that

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 10:00 pm
by DennisMe
Thanks Zazzium, that trick of yours is gonna come in really handy!

Re: How does user change their own password?

Posted: Tue Jan 08, 2013 10:27 pm
by johan
hi,

That's nice. What a little idea can do...

Johan