Home » Developer & Programmer » Application Express & MOD_PLSQL » Creating page for reset password (4.0)
Creating page for reset password [message #551874] Sat, 21 April 2012 12:44 Go to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
How do you do the following please

Current password textbox
new password textbox


CHANGE PASSWORD button


I need help making the 'Change password' button do:

1. check 'current password textbox' = user_password from helpdesk_user WHERE (LOGGED IN NAME) = user_login
if password is correct go to step 2 if not error message displays.

2. change user_password from helpdesk_user to 'new password textbox'

[Updated on: Sat, 21 April 2012 17:52]

Report message to a moderator

Re: Creating page for reset password [message #551910 is a reply to message #551874] Sun, 22 April 2012 08:02 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
can someone help please?
Re: Creating page for reset password [message #551919 is a reply to message #551910] Sun, 22 April 2012 10:12 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
One option is to create validation on CURRENT PASSWORD item that fires when CHANGE PASSWORD button is pressed. Code might look like this:
declare
  l_x varchar2(1);
begin
  select 'x'
    into l_x
    from helpdesk_user
    where user_name = :APP_USER
      and user_pwd = :P2_OLD_PWD;

  update helpdesk_user set
    user_pwd = :P2_NEW_PWD
    where user_name = :APP_USER;

  return (true);
exception
  when no_data_found then
    return (false);
end;
Re: Creating page for reset password [message #551920 is a reply to message #551919] Sun, 22 April 2012 10:16 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
can a code be put into the Change password button instead? I think that will be more simple.. would it be a dynamic action?
Re: Creating page for reset password [message #551923 is a reply to message #551920] Sun, 22 April 2012 10:35 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Feel free to try all options you find appropriate; then choose the one you are the most satisfied with.
Re: Creating page for reset password [message #551926 is a reply to message #551923] Sun, 22 April 2012 10:59 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
could you help me with this? i'll try on a dynamic action:

Event: change
Select type: Item(s)
Item(s): P21_CURRENTPASS <---thats the current passsword texbox
Condition: Equal to
Value: (select user_password
from helpdesk_user
where user_login = :APP_USER)

is the value supposed to be like that? thanks in advanced

as a test i did if true, message "correct pass"
if false, message "incorrect" however both are showing "incorrect" message.

[Updated on: Sun, 22 April 2012 11:00]

Report message to a moderator

Re: Creating page for reset password [message #551933 is a reply to message #551926] Sun, 22 April 2012 13:04 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As far as I know, you can't do it that way. Value can not be a query that returns value(s) - you should have typed current password (i.e. hard-code it), which is useless (as it would work only once, for exactly one user).

It means that condition shouldn't be used at all. As a TRUE action, you'd have to do something like I did in a validation - write PL/SQL code that would check whether password entered by a user is equal to the one stored in a table and - based on that answer - do *something*.
Re: Creating page for reset password [message #551936 is a reply to message #551933] Sun, 22 April 2012 13:21 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
how long would you think this would take to create (using the method you suggested, not dynamic action)? do you mind explaining a bit better what to do to that code?

[Updated on: Sun, 22 April 2012 13:21]

Report message to a moderator

Re: Creating page for reset password [message #551937 is a reply to message #551936] Sun, 22 April 2012 13:25 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
also as an idea, I can create a hidden textbox which contains the actual password of logged in user... is it possible to do a quicker method of changing password by validating CURRENT PASSWORD with (HIDDEN TEXT BOX REAL PASSWORD)?
so
Current password textbox
New password textbox
(HIDDEN TEXTBOX Containing real password from database)

Change password button

[Updated on: Sun, 22 April 2012 13:26]

Report message to a moderator

Re: Creating page for reset password [message #551940 is a reply to message #551937] Sun, 22 April 2012 13:32 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Validation method I suggested would take a few moments (as it requires only copy/paste and adjusting table/column names).

As of "another idea" you mentioned (with a hidden item): as I said - experiment as much as you want. That's a good way to learn how things work.
Re: Creating page for reset password [message #551944 is a reply to message #551940] Sun, 22 April 2012 13:43 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
cool I will go for the method you suggested... I need this part done within a few hours so if you can help me further would be super!!
So i should create, Page control on this page --> Validation --> Item Validation ---> Item to be validated p21_Currentpass --> what next? sql? p sql
Re: Creating page for reset password [message #551945 is a reply to message #551944] Sun, 22 April 2012 13:59 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What next?

What do you think (look at my code carefully)? Does it look like SQL or PL/SQL to you? Do you see the RETURN statement? What datatype does it return?
Re: Creating page for reset password [message #551946 is a reply to message #551945] Sun, 22 April 2012 14:10 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
thank you! Smile and to finish this off, if successfull password change, how to give the user a confirmation messag that password change is succesfull? does this go in the same validation?
Re: Creating page for reset password [message #551947 is a reply to message #551946] Sun, 22 April 2012 14:18 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
currently it just changes password and refreshs to same page
Re: Creating page for reset password [message #551976 is a reply to message #551947] Mon, 23 April 2012 01:20 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Include the following statement between UPDATE and RETURN (TRUE):
  update ...

  apex_application.g_print_success_message := 'Password successfully changed';

  return (true);
  ...
Re: Creating page for reset password [message #552059 is a reply to message #551976] Mon, 23 April 2012 06:38 Go to previous messageGo to next message
newprogrammerSQ
Messages: 48
Registered: April 2012
Member
declare
  l_x varchar2(1);
begin
  select 'x'
    into l_x
    from helpdesk_user
    where user_login = :APP_USER
      and user_password = :P21_CURRENTPASS;

  update helpdesk_user set
    user_password = :P21_NEWPASS
    where user_login = :APP_USER;
apex_application.g_print_success_message := 'Password successfully changed';
  return (true);
exception
  when no_data_found then
    return (false);
end;


however no affect.. is it in right place?
Re: Creating page for reset password [message #552099 is a reply to message #552059] Mon, 23 April 2012 09:16 Go to previous messageGo to next message
c_stenersen
Messages: 254
Registered: August 2007
Senior Member
What I would normally do is add any database actions which process data as processes on the page rather than doing the actual updates in the validations. It makes it more obvious for anyone watching the page development interface later on distinguish between what is actually doing any real update/insert/delete on the tables, and what is just validating that the input is correct. (And give them sensible names, and it should be easy to see what they do.) So then in the validation I would do as Littlefoot does, fetch the current password to see if it matches, and if not then return false. But I'd add an after submit process to do the actual update instead of doing it in the validation. The process then has a field where you can specify the success message to be given.

So in your validation:
declare
  l_x varchar2(1);
begin
  select 'x'
    into l_x
    from helpdesk_user
    where user_login = :APP_USER
      and user_password = :P21_CURRENTPASS;
  return (true);
exception
  when no_data_found then
    return (false);
end;


Then in an after submit process:
begin
  update helpdesk_user set
    user_password = :P21_NEWPASS
    where user_login = :APP_USER;
end;

And for this after submit process you go down to "Messages" and you can give in what the success message should be. In your case: Password successfully changed.
Then you don't need to call g_print_success_message.
Re: Creating page for reset password [message #552123 is a reply to message #552099] Mon, 23 April 2012 11:39 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Much better than my "all-in-one" idea.
Re: Creating page for reset password [message #552496 is a reply to message #552123] Thu, 26 April 2012 05:28 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi c_stenersen and newprogrammerSQ,
I also tried the above steps but am getting the following error,



Error processing validation.
ORA-06550: line 1, column 29: PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character se

Please Help me to solve this issue.

Thank you,
Regards,
gurujothi
Re: Creating page for reset password [message #552497 is a reply to message #552496] Thu, 26 April 2012 05:30 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Where did you put that code? Is it source type correctly set?
Re: Creating page for reset password [message #552498 is a reply to message #552497] Thu, 26 April 2012 05:37 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
Thank you for your instant reply,
I explain What I did is,

For current_password item I have created the validation and I put the code in
PL/SQL Expression as follows,

declare
l_x varchar2(1);
begin
select upper(username) into l_x
from login_table
where username = :P7_USERNAME
and password = :P7_CURRENT_PASSWORD;
return (true);
exception
when no_data_found then
return (false);
end;

Then I have created the processes in page rendering region,
Process point is On Submit-after computations and validations,
In the source I put the following code,

begin
update login_table set
password = :P7_NEW_PASSWORD
where upper(username) = :APP_USER;
end;

Thank you.
Re: Creating page for reset password [message #552500 is a reply to message #552498] Thu, 26 April 2012 05:42 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
I wrongly specified this one,
:P4_CURRENT_PASSWORD;Instead of this one :P7_CURRENT_PASSWORD;

now it showing another error,
ORA-00920: invalid relational operator
Re: Creating page for reset password [message #552502 is a reply to message #552500] Thu, 26 April 2012 05:45 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is complaining now? Is it a validation or a process?
Re: Creating page for reset password [message #552504 is a reply to message #551874] Thu, 26 April 2012 05:50 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
This is the error am getting,
Error processing validation.
ORA-00920: invalid relational operator

Thank you.
Re: Creating page for reset password [message #552506 is a reply to message #552504] Thu, 26 April 2012 05:54 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Huh, you wrongly copied (pasted) code we discussed here.

This fails, because USERNAME is most probably not just 1 character in length (and you declared a variable as VARCHAR2(1):
declare
  l_x varchar2(1);
begin
  select upper(username) into l_x
It is not that you should really select username - select *anything* (such as 'x'), just to know that a record exists.

So, what happens if you modify the code as suggested in previous messages?
Re: Creating page for reset password [message #552515 is a reply to message #552506] Thu, 26 April 2012 06:28 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
I changed the code like,
declare
l_x varchar2(30);
begin
select username into l_x
from login_table
where username = :P7_USERNAME
and password = :P7_CURRENT_PASSWORD;
return (true);
exception
when no_data_found then
return (false);
end;


and

begin
update login_table set
password = :P7_NEW_PASSWORD
where upper(username) = :APP_USER;
end;


but still am getting this error,
am using the login_table for the login page, it has the only two fields, username and password.

and in the change password wizard I have four fields,
1.username,
2.Current_password,
3.New_password
4.Retype_password
Now how can I use these codes or what I have to do?
Please solve my issue,

Thank you.
Re: Creating page for reset password [message #552517 is a reply to message #552515] Thu, 26 April 2012 06:32 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
On the second look, ORA-00920 means
Oracle
ORA-00920: Invalid relational operator

Cause: A search condition was entered with an invalid or missing relational operator.

Action: Include a valid relational operator such as =, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition.


As far as I can see, there's nothing wrong with code you posted. Do you, perhaps, use conditions or some other code that raises that error?
Re: Creating page for reset password [message #552518 is a reply to message #552517] Thu, 26 April 2012 06:38 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
Now am getting this error Mad

Error processing validation.
ORA-06550: line 1, column 29: PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character se
Re: Creating page for reset password [message #552519 is a reply to message #552518] Thu, 26 April 2012 06:42 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Some time ago I asked you whether its type is correctly set. Open that validation and read what's in "Type" property. It should be "Function returning Boolean".
Re: Creating page for reset password [message #552522 is a reply to message #552519] Thu, 26 April 2012 06:50 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
Sorry I wrongly chosen PLSQL expression,
now I changed and its working now,
Thank you so much,
Is this mpossible to show the username who logged in in the username field by default?
Re: Creating page for reset password [message #552524 is a reply to message #552522] Thu, 26 April 2012 06:55 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
To show username: create a text item whose source is "Item (application or page item name)". Put
APP_USER
into "Source value or expression".
Re: Creating page for reset password [message #552525 is a reply to message #552524] Thu, 26 April 2012 07:00 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
I put that but still showing blank,
Re: Creating page for reset password [message #552526 is a reply to message #552525] Thu, 26 April 2012 07:04 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Works fine for me. Did you do it EXACTLY as I told you? Did you put APP_USER in uppercase?
Re: Creating page for reset password [message #552527 is a reply to message #552525] Thu, 26 April 2012 07:07 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
One more question I want to check whether the both entered new_password and retype are same, I tried the validation it showing error always even if it is right.Please tel me to check the two fields for same value.
Thank you.
Re: Creating page for reset password [message #552529 is a reply to message #552527] Thu, 26 April 2012 07:15 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
You told to create one text item,
as I told already The change password page has 4 fields,
in that 1st field is username , here only I want to show the username who is logged in by default when they are coming into the change password page.
Thank you.
Re: Creating page for reset password [message #552530 is a reply to message #552527] Thu, 26 April 2012 07:19 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Create validation whose type is "Function returning Boolean":
return (:P2_NEW_PASSWORD = :P2_RETYPE_PASSWORD);
Set "Always execute" to YES.

(You'll probably need to change item names.)
Re: Creating page for reset password [message #552536 is a reply to message #552530] Thu, 26 April 2012 07:40 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,
Yes its working now,
Thank you so much but still that username is not coming by default Embarassed


Thank you.
Re: Creating page for reset password [message #552538 is a reply to message #552536] Thu, 26 April 2012 07:44 Go to previous messageGo to next message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Did you put APP_USER into "Default" or "Source"?
icon6.gif  Re: Creating page for reset password [message #552539 is a reply to message #552536] Thu, 26 April 2012 07:53 Go to previous messageGo to next message
gurujothi
Messages: 79
Registered: January 2012
Location: Banglore
Member
Hi Littlefoot,

In source I selected source type as 'plsql expression or function'

and in source value or expression I given ':APP_USER' and now its working,
Really Thank you so much for your help,Today I learnt something because of you,,
Thank you.
Regards,
gurujothi Smile
Re: Creating page for reset password [message #552593 is a reply to message #552539] Thu, 26 April 2012 14:21 Go to previous messageGo to previous message
Littlefoot
Messages: 19321
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You're welcome.
Previous Topic: How to configure more than one database in weblogic
Next Topic: How to redirect to different pages based on userneme from login page in apex4.1
Goto Forum:
  


Current Time: Mon Jul 28 14:55:20 CDT 2014

Total time taken to generate the page: 0.11314 seconds