Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

How does user change their own password?

tschutter
Posts: 15
Joined: Fri Nov 23, 2012 11:31 pm

How does user change their own password?

Unread post 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?
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: How does user change their own password?

Unread post 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
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: How does user change their own password?

Unread post 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
mlgeek
Posts: 23
Joined: Tue May 08, 2012 8:24 pm

Re: How does user change their own password?

Unread post 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!
zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: How does user change their own password?

Unread post 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
mlgeek
Posts: 23
Joined: Tue May 08, 2012 8:24 pm

Re: How does user change their own password?

Unread post by mlgeek »

Cool. Thanks, Zazzium- much appreciated.
mlgeek
Posts: 23
Joined: Tue May 08, 2012 8:24 pm

Re: How does user change their own password?

Unread post 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.
zazzium
Posts: 84
Joined: Mon Jul 04, 2011 12:52 am

Re: How does user change their own password?

Unread post 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
DennisMe
Posts: 10
Joined: Thu Jan 03, 2013 10:21 am

Re: How does user change their own password?

Unread post by DennisMe »

Thanks Zazzium, that trick of yours is gonna come in really handy!
johan
Posts: 392
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium

Re: How does user change their own password?

Unread post by johan »

hi,

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

Johan
Locked