Skip to Content Skip to Menu

[SOLVED] Trying to Verify Current Password CB field against Joomla user password

10 years 7 months ago #242484 by prestoproducts
Okay, when I tried this:
Code:
<?php Global $_CB_framework; $myId = $_CB_framework->myId(); $user =& CBuser::getUserDataInstance( $myId ); $plainTextPassword = '123456'; $password = $user->verifyPassword( $plainTextPassword ); echo $password; ?>

I get a value of 1 if I use the matching password. If I change to a non matching value of logged in user for $plainTextPassword, I get no display. So am I correct to assume that a returned value of 1 means that the password is a match?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 7 months ago - 10 years 7 months ago #242485 by krileon

So am I correct to assume that a returned value of 1 means that the password is a match?

Yes, 1/true is matching 0/false is mismatch. Booleans don't echo as true/false. They'll echo as 1 or null. When debugging always be sure to use var_dump( VARIABLE HERE ); to properly debug output as echo is not accurate to type.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 10 years 7 months ago by krileon.

Please Log in or Create an account to join the conversation.

10 years 7 months ago - 10 years 7 months ago #242506 by prestoproducts
Great! So now the last thing is how can I change the input from displaying the numbers like this:



to be hidden like a typical password field:



I tried creating a cb password field type, but that brought a second field with it.


Also, for the CB Auto Action Trigger, I have the following conditional:



My thought here is that the trigger will only run the script if the user tries to edit the password field on their profile. When I just tested this I see that the script is running at all profile updates. The trigger is set to fire onBeforeUserUpdate. How can I adjust the conditional to only run if the user is trying to change the password value?
Last edit: 10 years 7 months ago by prestoproducts.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 7 months ago #242551 by krileon
Only password fieldtypes are going to hide the value like that. The password substitution is always going to have a value. It's either going to be plaintext or it's going to be encrypted, but it should always have a value in most cases. To test if the password actually changed you can do the below conditional.

Conditional 1: [var1_password] Not Empty
Conditional 2: [var1_password] Not Equal To [var3_password]

That checks the raw trigger user object password values against one another (var1 is new object, var3 is old object) to test for a change and only if the password isn't null (no change).


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: prestoproducts

Please Log in or Create an account to join the conversation.

10 years 7 months ago - 10 years 7 months ago #242556 by prestoproducts
That seems to do exactly what I wanted, thanks. So, the only thing is the hidden value of the text input. Is there a way to add custom CSS to hide the input values, or some other option?

Ultimately I need just a single value rather than the 2 that come with a password type. If I use the password type, is there a way to hide the second field? If so, would an error be thrown out since the second field is hidden?



After researching this a bit, could this configuration be used to hide the field input?

jsfiddle.net/kPJbU/

If so, what is the best way to set the triggers for the jQuery and onClick event?
Last edit: 10 years 7 months ago by prestoproducts.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 7 months ago #242564 by krileon
You can add jQuery to the page using CB Auto Actions and its Code action with Method set to jQuery then use the profile edit display trigger.

For CB 2.0 will review implementing a parameter to disable usage of the verify password field so you can have a single password field as you're needing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: prestoproducts

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum