Skip to content
⌘ NSIS Forum Archive

How to confirm a password

10 posts

M4RC II#

How to confirm a password

Hy, I have make an password page. The user must enter there a password for his server.

How can I make it, that the user must confirm the password.

If the password isn't the same there must come an message box with the text.

The passwords aren't the same.

If the user hasn't write an password in the confirm field there should be come the message box:

You haven't fill-in the confirm password field.

How can I do this?

Please help me.

Could you write the code in my password.nsh?
Afrow UK#
Page Custom CustomShow CustomLeave

!define PASS xyz123

LangString BadPass ${LANG_ENGLISH} "Incorrect password!"

Function CustomLeave
ReadINIStr $R0 "$PLUGINSDIR\IOFile.ini" "Field #" "State"
StrCmp $R0 "${PASS}" +3
MessageBox MB_OK|MB_ICONSTOP "$(BadPass)"
Abort
FunctionEnd
Using InstallOptions isn't very secure for passwords because the password that you type will be in the INI file until you close the installer. If you want added security you can use my PassDialog plugin which has a password dialog among others (such as user name and password).



-Stu
M4RC II#
Hy thx for your reply but that it isn't what i mean.

Perhaps you can download my password.rar than you can sea it.

The user enter an password and the password will be copy in the (in my example) Example.txt

In my realy installer it is a password for his server. So i would only that he must enter his password and afer this he must confirm his password.

Thx Marc
I hope that you understand my question. (I can't speak very good english)
M4RC II#
hy I hope I've understood what you've mean. I think that it isn't good only the make an other "password" box. When the user write a wrong password in the second password box it wouldn't be compare with the first password.

Isn't it possible to make it so that when the user must write his password for the game server (so far it is now) and after this he must remember this password in an other password field.

Then it should be check if it are the sames.
Now Advanced replace in file copy the password in the file from the server.

Here is my function code:



Function PasswordPage

!insertmacro MUI_HEADER_TEXT "Configuration" "Please insert an password."
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "password.ini"


FunctionEnd

LangString NoPassword ${LANG_ENGLISH} "Please insert an password!"

; Page Leave Feautures
Function PageLeavePassword

!insertmacro MUI_INSTALLOPTIONS_READ $R0 "Password.ini" "Field 1" "State"
${If} $R0 != ""
Push "Passwort" #-- text to be replaced within the " "
Push "$R0" #-- replace with anything within the " "
Push all #-- replace all occurrences
Push all #-- replace all occurrences
Push $INSTDIR\Example.txt #-- file to replace in
Call AdvReplaceInFile #-- Call the Function
${Else}
MessageBox MB_OK|MB_ICONINFORMATION $(NoPassword)
Abort
${EndIf}

FunctionEnd
Afrow UK#
"When the user write a wrong password in the second password box it wouldn't be compare with the first password."
Why not? Compare the passwords from the password fields with StrCmp, then if they are the same you only then need to compare one password with the actual server password.

-Stu
M4RC II#
pls help me afrow uk

Could you write me the code which compare the second password with the first ?
Afrow UK#
Very simple and logical...


Page Custom CustomShow CustomLeave

!define PASS xyz123

LangString PassDoNotMatch ${LANG_ENGLISH} "Passwords do not match!"
LangString BadPass ${LANG_ENGLISH} "Incorrect password!"

Function CustomLeave
ReadINIStr $R0 "$PLUGINSDIR\IOFile.ini" "Field #" "State"
ReadINIStr $R1 "$PLUGINSDIR\IOFile.ini" "Field #+1" "State"
StrCmp $R0 $R1 +3
MessageBox MB_OK|MB_ICONSTOP "$(PassDoNotMatch)"
Abort
StrCmp $R0 "${PASS}" +3
MessageBox MB_OK|MB_ICONSTOP "$(BadPass)"
Abort
FunctionEnd