Correct password but wrong ?
#1

Hi !

I have a problem for a while. I took the tutorial of Kush about the "Login and Register System" and I have a problem. When the dialog login appear, I write my password that I previously register but it say me that my password is wrong ! But I'm sure, my password has been CORRECTLY write ! Also, I hashed my password with the plugins Whirlpool.

The code :

Код:
case DIALOG_LOGIN:
       {
        if (!response) return Kick(playerid);
        if(response)
         {
          new hashpass[129];
          WP_Hash(hashpass,sizeof(hashpass),inputtext);
		  if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,3,"Une erreur est survenue","Vous n'avez rien saisie.\nTaper votre mot de passe ci-dessous pour vous connecter.","Se connecter","Quitter");
          if(strcmp(hashpass,JoueurInfo[playerid][jMDP],true))
           {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
            ShowPlayerDialog(playerid,DIALOG_SUCCESS_2,0,"Connection rйussi !","Vous avez йtй correctement connectй au serveur.\nVous pouvez maintenant jouer. Bonne chance !","Jouer !","");
           }
           else
           {
			ShowPlayerDialog(playerid,DIALOG_LOGIN,3,"Une erreur est survenue","Vous avez taper un mauvais mot de passe.\nTaper votre mot de passe ci-dessous pour vous connecter.","Se connecter","Quitter");
			return 1;
		   }
         }
       }
(Don't pay attention to language)

Thanks for your help !
Reply
#2

Quote:

if(strcmp(hashpass,JoueurInfo[playerid][jMDP],true))

strcmp returns 1 if both strings are not equal, and even not speaking your language I can notice you're passing that to the success part of the login. Check if it's false if you want to check if two strings are equal.
Reply
#3

Quote:
Originally Posted by CuervO
Посмотреть сообщение
strcmp returns 1 if both strings are not equal
Not only. It returns either 1 or -1, it depends on which string is bigger.

Although what CuervO said is the solution. Your code basically shows the login dialog if the passwords are the same so you need to change:
pawn Код:
if(strcmp(hashpass,JoueurInfo[playerid][jMDP],true))
to:
pawn Код:
if(!strcmp(hashpass,JoueurInfo[playerid][jMDP]))
ignorecase doesn't matter because Whirlpool always uses upper case.
Reply
#4

Quote:
Originally Posted by CuervO
Посмотреть сообщение
strcmp returns 1 if both strings are not equal, and even not speaking your language I can notice you're passing that to the success part of the login. Check if it's false if you want to check if two strings are equal.
I don't really understand what you would I do.. :/ You want I check if my hashed password is not equal to my variable password and if it is equal, that will login me ?

I do like this :

Код:
if(!strcmp(hashpass,JoueurInfo[playerid][jMDP]))
           {
            INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
			ShowPlayerDialog(playerid,DIALOG_SUCCESS_2,0,"Connection rйussi !","Vous avez йtй correctement connectй au serveur.\nVous pouvez maintenant jouer. Bonne chance !","Jouer !","");
		   }
	      else
           {
            ShowPlayerDialog(playerid,DIALOG_LOGIN,3,"Une erreur est survenue","Vous avez taper un mauvais mot de passe.\nTaper votre mot de passe ci-dessous pour vous connecter.","Se connecter","Quitter");
			return 1;
		   }
(The new code)

EDIT: I didn't see your response Konstantinos, i'll go test it !

EDIT2: That work but now there are other problems ! If I write a different password of mine, that login me but this is not my password ! Also, my .ini file is doesn't create in scriptfiles but I'm sure my #define path is good !

Here :
Код:
#define PATH "LSGW/Comptes/%s.ini"
(Comptes mean Accounts)
Reply
#5

Up (Check above for the new problem)
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)