Password change by the user

Discuss issues and ideas you have to configuring displays with PowerVision
mikwin
Posts: 7
Joined: Thu Jan 19, 2012 3:20 pm

Password change by the user

Post by mikwin » Tue Jul 16, 2013 9:22 pm

Hello, I have the following script for the pasword:

void $SCR check password$ ()
{
string temp;
cultureGetString(StringIDs.PasswordString,temp,0);

if ((temp == "LVLI") || (temp == "123"))
{
sendEvent (EventIDs.TR_password_correct_lvl1);

else
{
sendEvent (EventIDs.TR_password_wrong);
}
cultureSetString(StringIDs.PasswordString,"",true);
}

void $SCR Reset password$ ()
{
cultureSetString(StringIDs.PasswordString,"",true);
}


I want to let the iser to change the password. How I can do that?

Tks in advance.
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: Password change by the user

Post by ksaenz » Wed Jul 17, 2013 7:56 am

Hello mikwin,

You can store the password chosen by the user in a text file

Code: Select all

string temp;
file f;

cultureGetString(StringIDs.PasswordString,temp,0);
	
if( f.open("password.txt", "w") >= 0 ) 
{
   f.writeString( temp ); 
   f.close();
}
And read it out to compare it when needed

Code: Select all

file f;
string validPwd;
	
if( f.open("password.txt", "r") >= 0 ) 
{
   f.readLine( validPwd ); 
   f.close();
}
else
{
   validPwd = "LVLI"; // default password
}
Regards,
ksaenz
mikwin
Posts: 7
Joined: Thu Jan 19, 2012 3:20 pm

Re: Password change by the user

Post by mikwin » Wed Jul 17, 2013 2:50 pm

Thank you ksaenz. Ok for the script, but is that will replace or to introduced in the existting script and where?

I will send you my file, if you can help me to fix it.
ksaenz
Enovation Controls Development
Enovation Controls Development
Posts: 263
Joined: Thu Aug 19, 2010 7:53 am

Re: Password change by the user

Post by ksaenz » Wed Jul 17, 2013 3:03 pm

The first piece of code should be in a script that runs after the user enters the new password to be saved.

The second piece code goes in your $SCR check password$ script before you do the comparison, you will compare to the validPwd variable instead of the hard coded strings.

Code: Select all

if ( temp == validPwd )
{
   sendEvent (EventIDs.TR_password_correct_lvl1);
}
else 
{
   sendEvent (EventIDs.TR_password_wrong);
}

cultureSetString(StringIDs.PasswordString,"",true);
You can me your code via PM and I can help you.