diff --git a/swad_ID.c b/swad_ID.c index d1269b884..7b9fd181e 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -734,7 +734,7 @@ void ID_RemoveMyUsrID (void) ID_GetListIDsFromUsrCod (&Gbl.Usrs.Me.UsrDat); /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ @@ -850,7 +850,7 @@ void ID_NewMyUsrID (void) ID_GetListIDsFromUsrCod (&Gbl.Usrs.Me.UsrDat); /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ diff --git a/swad_account.c b/swad_account.c index 02b3d18a4..3c6bac430 100644 --- a/swad_account.c +++ b/swad_account.c @@ -74,6 +74,7 @@ static void Acc_ShowFormCheckIfIHaveAccount (const char *Title); static void Acc_WriteRowEmptyAccount (unsigned NumUsr,const char *ID,struct UsrData *UsrDat); static void Acc_ShowFormRequestNewAccountWithParams (const char *NewNicknameWithoutArroba, const char *NewEmail); +static void Acc_ShowFormChgMyAccount (void); static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES_NICKNAME_FROM_FORM + 1], char *NewEmail, char *NewEncryptedPassword); @@ -113,7 +114,7 @@ void Acc_ShowFormMyAccount (void) extern const char *Txt_Before_creating_a_new_account_check_if_you_have_been_already_registered; if (Gbl.Usrs.Me.Logged) - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); else // Not logged { /***** Links to other actions *****/ @@ -423,11 +424,24 @@ void Acc_ShowFormGoToRequestNewAccount (void) Box_EndBox (); } +/*****************************************************************************/ +/************** Show forms to change my account and my password **************/ +/*****************************************************************************/ + +void Acc_ShowFormChgMyAccountAndPwd (void) + { + /***** Show form to change my account *****/ + Acc_ShowFormChgMyAccount (); + + /***** Show form to change my password *****/ + Pwd_ShowFormChgMyPwd (); + } + /*****************************************************************************/ /*********************** Show form to change my account **********************/ /*****************************************************************************/ -void Acc_ShowFormChangeMyAccount (void) +static void Acc_ShowFormChgMyAccount (void) { extern const char *Hlp_PROFILE_Account; extern const char *Txt_Before_going_to_any_other_option_you_must_fill_your_nickname; @@ -463,12 +477,13 @@ void Acc_ShowFormChangeMyAccount (void) if (Gbl.Usrs.Me.ConfirmEmailJustSent) Mai_ShowMsgConfirmEmailHasBeenSent (); - /***** Put links to change my password and to remove my account*****/ - fprintf (Gbl.F.Out,"
"); - Pwd_PutLinkToChangeMyPassword (); + /***** Put link to remove my account *****/ if (Acc_CheckIfICanEliminateAccount (Gbl.Usrs.Me.UsrDat.UsrCod)) + { + fprintf (Gbl.F.Out,"
"); Acc_PutLinkToRemoveMyAccount (); - fprintf (Gbl.F.Out,"
"); + fprintf (Gbl.F.Out,"
"); + } /***** Start box and table *****/ Box_StartBoxTable (NULL,Txt_User_account,NULL, @@ -859,7 +874,7 @@ void Acc_AfterCreationNewAccount (void) Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); /***** Show form with account data *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } } diff --git a/swad_account.h b/swad_account.h index c4634708d..aea10aff0 100644 --- a/swad_account.h +++ b/swad_account.h @@ -56,7 +56,7 @@ void Acc_ShowFormMyAccount (void); void Acc_CheckIfEmptyAccountExists (void); void Acc_ShowFormGoToRequestNewAccount (void); -void Acc_ShowFormChangeMyAccount (void); +void Acc_ShowFormChgMyAccountAndPwd (void); bool Acc_CreateMyNewAccountAndLogIn (void); void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount); void Acc_AfterCreationNewAccount (void); diff --git a/swad_action.c b/swad_action.c index dd2bbe4fa..40312c38f 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2789,9 +2789,9 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActFrmPwdOth */{1464,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pwd_ShowFormOthPwd ,NULL}, /* ActFrmPwdStd */{1465,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pwd_ShowFormOthPwd ,NULL}, /* ActFrmPwdTch */{1466,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pwd_ShowFormOthPwd ,NULL}, - /* ActChgPwdOth */{1467,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd1 ,Pwd_UpdateOtherPwd2 ,NULL}, - /* ActChgPwdStd */{1468,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd1 ,Pwd_UpdateOtherPwd2 ,NULL}, - /* ActChgPwdTch */{1469,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd1 ,Pwd_UpdateOtherPwd2 ,NULL}, + /* ActChgPwdOth */{1467,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Pwd_ShowFormOthPwd ,NULL}, + /* ActChgPwdStd */{1468,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Pwd_ShowFormOthPwd ,NULL}, + /* ActChgPwdTch */{1469,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Pwd_ShowFormOthPwd ,NULL}, /* ActFrmMaiOth */{1475,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mai_ShowFormOthEmail ,NULL}, /* ActFrmMaiStd */{1476,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mai_ShowFormOthEmail ,NULL}, @@ -3131,8 +3131,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActNewMaiMe */{1088,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,May_NewMyUsrEmail ,NULL}, /* ActCnfMai */{1091,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mai_ConfirmEmail ,NULL}, - /* ActFrmChgMyPwd */{ 34,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Pwd_ShowFormChgPwd ,NULL}, - /* ActChgPwd */{ 35,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_ActChgMyPwd1 ,Pwd_ActChgMyPwd2 ,NULL}, + /* ActFrmChgMyPwd */{ 34,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_ShowFormChgMyAccountAndPwd ,NULL}, + /* ActChgPwd */{ 35,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_ActChgMyPwd ,Acc_ShowFormChgMyAccountAndPwd ,NULL}, /* ActReqRemMyAcc */{1430,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_AskIfRemoveMyAccount ,NULL}, /* ActRemMyAcc */{1431,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Acc_RemoveMyAccount ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index c0722ab9b..8f590967e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -355,10 +355,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.3.1 (2018-10-09)" +#define Log_PLATFORM_VERSION "SWAD 18.3.2 (2018-10-09)" #define CSS_FILE "swad18.3.css" #define JS_FILE "swad17.17.1.js" /* + Version 18.3.2: Oct 09, 2018 Changes in form to change password. (234935 lines) Version 18.3.1: Oct 09, 2018 Changes in layout of session option. (234904 lines) Version 18.3: Oct 09, 2018 New icon in breadcrumb to go to user's courses. (234874 lines) Copy the following icons to icon public directory: diff --git a/swad_global.h b/swad_global.h index 68f38d918..6bc73031e 100644 --- a/swad_global.h +++ b/swad_global.h @@ -407,7 +407,6 @@ struct Globals } Lst[Cfg_MAX_CONNECTED_SHOWN]; } Connected; char FileNamePhoto[NAME_MAX + 1]; // File name (with no path and no .jpg) of the temporary file with the selected face - bool Error; // To signal that an error has happened Enr_RegRemOneUsrAction_t RegRemAction; // Enrolment action } Usrs; struct diff --git a/swad_mail.c b/swad_mail.c index 507573f9a..72d799e14 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -1400,7 +1400,7 @@ void Mai_RemoveMyUsrEmail (void) Mai_RemoveEmail (&Gbl.Usrs.Me.UsrDat); /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ @@ -1479,7 +1479,7 @@ void May_NewMyUsrEmail (void) Mai_NewUsrEmail (&Gbl.Usrs.Me.UsrDat,true); // It's me /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ diff --git a/swad_nickname.c b/swad_nickname.c index d11765426..8d7a57f3a 100644 --- a/swad_nickname.c +++ b/swad_nickname.c @@ -324,7 +324,7 @@ void Nck_RemoveNick (void) Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_delete_your_current_nickname); /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ @@ -419,7 +419,7 @@ void Nck_UpdateNick (void) Gbl.Alert.Txt); /***** Show my account again *****/ - Acc_ShowFormChangeMyAccount (); + Acc_ShowFormChgMyAccountAndPwd (); } /*****************************************************************************/ diff --git a/swad_password.c b/swad_password.c index ea9c0de82..d36ea1b80 100644 --- a/swad_password.c +++ b/swad_password.c @@ -55,6 +55,8 @@ extern struct Globals Gbl; // and another user can not change his/her password to this #define Pwd_MAX_OTHER_USERS_USING_THE_SAME_PASSWORD 2 +#define Pwd_PASSWORD_SECTION_ID "password_section" + /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ @@ -158,7 +160,7 @@ void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void) /*********************** Change my password in database **********************/ /*****************************************************************************/ -void Pwd_ActChgMyPwd1 (void) +void Pwd_ActChgMyPwd (void) { extern const char *Txt_You_have_not_written_twice_the_same_new_password; extern const char *Txt_Your_password_has_been_changed_successfully; @@ -167,13 +169,14 @@ void Pwd_ActChgMyPwd1 (void) char NewPlainPassword[2][Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]; char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1]; + Gbl.Alert.Type = Ale_NONE; + /***** Get plain password from form *****/ Par_GetParToText ("UsrPwd",PlainPassword,Pwd_MAX_BYTES_PLAIN_PASSWORD); /***** Encrypt password *****/ Cry_EncryptSHA512Base64 (PlainPassword,Gbl.Usrs.Me.LoginEncryptedPassword); - Gbl.Usrs.Error = true; if (Pwd_CheckCurrentPassword ()) { Par_GetParToText ("Paswd1",NewPlainPassword[0],Pwd_MAX_BYTES_PLAIN_PASSWORD); @@ -181,12 +184,17 @@ void Pwd_ActChgMyPwd1 (void) /***** Check if I have written twice the same password *****/ if (strcmp (NewPlainPassword[0],NewPlainPassword[1])) + { // Passwords don't match - sprintf (Gbl.Alert.Txt,"%s",Txt_You_have_not_written_twice_the_same_new_password); + Gbl.Alert.Type = Ale_WARNING; + sprintf (Gbl.Alert.Txt,"%s", + Txt_You_have_not_written_twice_the_same_new_password); + } else { Cry_EncryptSHA512Base64 (NewPlainPassword[0],NewEncryptedPassword); - if (Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword[0],NewEncryptedPassword, + if (Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword[0], + NewEncryptedPassword, Gbl.Usrs.Me.UsrDat.UsrCod)) // New password is good? { /* Update my data */ @@ -195,25 +203,18 @@ void Pwd_ActChgMyPwd1 (void) Ses_UpdateSessionDataInDB (); Enr_UpdateUsrData (&Gbl.Usrs.Me.UsrDat); - sprintf (Gbl.Alert.Txt,"%s",Txt_Your_password_has_been_changed_successfully); - Gbl.Usrs.Error = false; + Gbl.Alert.Type = Ale_SUCCESS; + sprintf (Gbl.Alert.Txt,"%s", + Txt_Your_password_has_been_changed_successfully); } } } else - sprintf (Gbl.Alert.Txt,"%s",Txt_You_have_not_entered_your_password_correctly); - } - -void Pwd_ActChgMyPwd2 (void) - { - /***** Write error message when updating password *****/ - Ale_ShowAlert (Gbl.Usrs.Error ? Ale_WARNING : - Ale_INFO, - Gbl.Alert.Txt); - - /***** Retry? *****/ - if (Gbl.Usrs.Error) - Pwd_ShowFormChgPwd (); + { + Gbl.Alert.Type = Ale_WARNING; + sprintf (Gbl.Alert.Txt,"%s", + Txt_You_have_not_entered_your_password_correctly); + } } /*****************************************************************************/ @@ -363,7 +364,7 @@ void Pwd_ChkIdLoginAndSendNewPwd (void) break; default: sprintf (Gbl.Alert.Txt,"Internal error: an email message has not been sent successfully." - " Error code returned by the script: %d", + " Error code returned by the script: %d", ReturnCode); Ale_ShowAlert (Ale_ERROR,Gbl.Alert.Txt); break; @@ -489,7 +490,7 @@ void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + /******************************** Update password ****************************/ /*****************************************************************************/ -void Pwd_UpdateOtherPwd1 (void) +void Pwd_UpdateOtherPwd (void) { extern const char *Txt_You_have_not_written_twice_the_same_new_password; extern const char *Txt_The_X_password_has_been_changed_successfully; @@ -497,7 +498,7 @@ void Pwd_UpdateOtherPwd1 (void) char NewPlainPassword[2][Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]; char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1]; - Gbl.Usrs.Error = true; + Gbl.Alert.Type = Ale_NONE; /***** Get other user's code from form and get user's data *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) @@ -508,12 +509,17 @@ void Pwd_UpdateOtherPwd1 (void) Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_BYTES_PLAIN_PASSWORD); if (strcmp (NewPlainPassword[0],NewPlainPassword[1])) + { // Paswords don't match - sprintf (Gbl.Alert.Txt,"%s",Txt_You_have_not_written_twice_the_same_new_password); + Gbl.Alert.Type = Ale_WARNING; + sprintf (Gbl.Alert.Txt,"%s", + Txt_You_have_not_written_twice_the_same_new_password); + } else { Cry_EncryptSHA512Base64 (NewPlainPassword[0],NewEncryptedPassword); - if (Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword[0],NewEncryptedPassword, + if (Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword[0], + NewEncryptedPassword, Gbl.Usrs.Other.UsrDat.UsrCod)) // New password is good? { /* Update other user's data */ @@ -521,32 +527,24 @@ void Pwd_UpdateOtherPwd1 (void) Pwd_BYTES_ENCRYPTED_PASSWORD); Enr_UpdateUsrData (&Gbl.Usrs.Other.UsrDat); + Gbl.Alert.Type = Ale_SUCCESS; sprintf (Gbl.Alert.Txt,Txt_The_X_password_has_been_changed_successfully, Gbl.Usrs.Other.UsrDat.FullName); - Gbl.Usrs.Error = false; } } } else - sprintf (Gbl.Alert.Txt,"%s",Txt_User_not_found_or_you_do_not_have_permission_); + { + Gbl.Alert.Type = Ale_WARNING; + sprintf (Gbl.Alert.Txt,"%s", + Txt_User_not_found_or_you_do_not_have_permission_); + } } else // User not found - sprintf (Gbl.Alert.Txt,"%s",Txt_User_not_found_or_you_do_not_have_permission_); - } - -void Pwd_UpdateOtherPwd2 (void) - { - /***** Write message when updating the password *****/ - if (Gbl.Alert.Txt[0]) - Ale_ShowAlert (Gbl.Usrs.Error ? Ale_WARNING : - Ale_INFO, - Gbl.Alert.Txt); - - if (Gbl.Usrs.Error) { - /***** Try again *****/ - Gbl.Usrs.Error = false; - Pwd_ShowFormOthPwd (); + Gbl.Alert.Type = Ale_WARNING; + sprintf (Gbl.Alert.Txt,"%s", + Txt_User_not_found_or_you_do_not_have_permission_); } } @@ -567,6 +565,7 @@ bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword, /***** Check if password is found in user's ID, first name or surnames of anybody *****/ if (Pwd_CheckIfPasswdIsUsrIDorName (PlainPassword)) // PlainPassword is a user's ID, name or surname { + Gbl.Alert.Type = Ale_WARNING; sprintf (Gbl.Alert.Txt,"%s",Txt_The_password_is_too_trivial_); return false; } @@ -575,6 +574,7 @@ bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword, if (Pwd_GetNumOtherUsrsWhoUseThisPassword (EncryptedPassword,UsrCod) > Pwd_MAX_OTHER_USERS_USING_THE_SAME_PASSWORD) { + Gbl.Alert.Type = Ale_WARNING; sprintf (Gbl.Alert.Txt,"%s",Txt_The_password_is_too_trivial_); return false; } @@ -644,6 +644,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword) /***** Check length of password *****/ if (LengthPassword < Pwd_MIN_BYTES_PLAIN_PASSWORD) // PlainPassword too short { + Gbl.Alert.Type = Ale_WARNING; sprintf (Gbl.Alert.Txt,Txt_The_password_must_be_at_least_X_characters, Pwd_MIN_CHARS_PLAIN_PASSWORD); return false; @@ -652,6 +653,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword) /***** Check spaces in password *****/ if (strchr (PlainPassword,(int) ' ') != NULL) // PlainPassword with spaces { + Gbl.Alert.Type = Ale_WARNING; sprintf (Gbl.Alert.Txt,"%s",Txt_The_password_can_not_contain_spaces); return false; } @@ -664,6 +666,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword) ItsANumber = false; if (ItsANumber) { + Gbl.Alert.Type = Ale_WARNING; sprintf (Gbl.Alert.Txt,"%s",Txt_The_password_can_not_consist_only_of_digits); return false; } @@ -675,7 +678,7 @@ bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword) /********************** Show form for changing my password *******************/ /*****************************************************************************/ -void Pwd_ShowFormChgPwd (void) +void Pwd_ShowFormChgMyPwd (void) { extern const char *Hlp_PROFILE_Password; extern const char *The_ClassForm[The_NUM_THEMES]; @@ -688,58 +691,71 @@ void Pwd_ShowFormChgPwd (void) extern const char *Txt_Set_password; bool IHaveAPasswordInDB = (bool) Gbl.Usrs.Me.UsrDat.Password[0]; - /***** Help message *****/ - if (!IHaveAPasswordInDB) // If I don't have a password in database... - Ale_ShowAlert (Ale_WARNING,Txt_Before_going_to_any_other_option_you_must_create_your_password); - else if (Gbl.Usrs.Me.LoginPlainPassword[0]) + /***** Start section *****/ + Lay_StartSection (Pwd_PASSWORD_SECTION_ID); + + /***** Show possible alert *****/ + Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt); + + /***** Success changing password ==> don't show form again *****/ + if (Gbl.Alert.Type != Ale_SUCCESS) { - if (!Pwd_FastCheckIfPasswordSeemsGood (Gbl.Usrs.Me.LoginPlainPassword)) - Ale_ShowAlert (Ale_WARNING,Txt_Your_password_is_not_secure_enough); + /***** Help message *****/ + if (!IHaveAPasswordInDB) // If I don't have a password in database... + Ale_ShowAlert (Ale_WARNING,Txt_Before_going_to_any_other_option_you_must_create_your_password); + else if (Gbl.Usrs.Me.LoginPlainPassword[0]) + { + if (!Pwd_FastCheckIfPasswordSeemsGood (Gbl.Usrs.Me.LoginPlainPassword)) + Ale_ShowAlert (Ale_WARNING,Txt_Your_password_is_not_secure_enough); + } + + /***** Start form *****/ + Act_FormStartAnchor (ActChgPwd,Pwd_PASSWORD_SECTION_ID); + + /***** Start box and table *****/ + Box_StartBoxTable (NULL,Txt_Password,NULL, + Hlp_PROFILE_Password,Box_NOT_CLOSABLE,2); + + /* Current password */ + if (IHaveAPasswordInDB) // If I have a password in database... + fprintf (Gbl.F.Out,"" + "" + "" + "" + "" + "" + "" + "", + The_ClassForm[Gbl.Prefs.Theme], + Txt_Current_password, + Pwd_MAX_CHARS_PLAIN_PASSWORD); + + /* Help message */ + fprintf (Gbl.F.Out,"" + ""); + sprintf (Gbl.Alert.Txt,Txt_Your_password_must_be_at_least_X_characters_and_can_not_contain_spaces_, + Pwd_MIN_CHARS_PLAIN_PASSWORD); + Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); + fprintf (Gbl.F.Out,"" + ""); + + /* New password */ + Pwd_PutFormToGetNewPasswordTwice (); + + /***** End table, send button and end box *****/ + Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON, + IHaveAPasswordInDB ? Txt_Change_password : + Txt_Set_password); + + /***** End form *****/ + Act_FormEnd (); } - /***** Start form *****/ - Act_FormStart (ActChgPwd); - - /***** Start box and table *****/ - Box_StartBoxTable (NULL,Txt_Password,NULL, - Hlp_PROFILE_Password,Box_NOT_CLOSABLE,2); - - /* Current password */ - if (IHaveAPasswordInDB) // If I have a password in database... - fprintf (Gbl.F.Out,"" - "" - "" - "" - "" - "" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_Current_password, - Pwd_MAX_CHARS_PLAIN_PASSWORD); - - /* Help message */ - fprintf (Gbl.F.Out,"" - ""); - sprintf (Gbl.Alert.Txt,Txt_Your_password_must_be_at_least_X_characters_and_can_not_contain_spaces_, - Pwd_MIN_CHARS_PLAIN_PASSWORD); - Ale_ShowAlert (Ale_INFO,Gbl.Alert.Txt); - fprintf (Gbl.F.Out,"" - ""); - - /* New password */ - Pwd_PutFormToGetNewPasswordTwice (); - - /***** End table, send button and end box *****/ - Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON, - IHaveAPasswordInDB ? Txt_Change_password : - Txt_Set_password); - - /***** End form *****/ - Act_FormEnd (); + /***** End section *****/ + Lay_EndSection (); } /*****************************************************************************/ @@ -822,54 +838,61 @@ void Pwd_ShowFormOthPwd (void) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; Act_Action_t NextAction; - /***** Get user whose password must be changed *****/ - if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) + /***** Show possible alert *****/ + Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt); + + /***** Success changing password ==> don't show form again *****/ + if (Gbl.Alert.Type != Ale_SUCCESS) { - if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + /***** Get user whose password must be changed *****/ + if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - /***** Start box *****/ - Box_StartBox (NULL,Txt_Password,NULL, - NULL,Box_NOT_CLOSABLE); - - /***** Show user's record *****/ - Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, - &Gbl.Usrs.Other.UsrDat,NULL); - - /***** Form to change password *****/ - /* Start form */ - switch (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { - case Rol_STD: - NextAction = ActChgPwdStd; - break; - case Rol_NET: - case Rol_TCH: - NextAction = ActChgPwdTch; - break; - default: // Guest, user or admin - NextAction = ActChgPwdOth; - break; + /***** Start box *****/ + Box_StartBox (NULL,Txt_Password,NULL, + NULL,Box_NOT_CLOSABLE); + + /***** Show user's record *****/ + Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST, + &Gbl.Usrs.Other.UsrDat,NULL); + + /***** Form to change password *****/ + /* Start form */ + switch (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role) + { + case Rol_STD: + NextAction = ActChgPwdStd; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActChgPwdTch; + break; + default: // Guest, user or admin + NextAction = ActChgPwdOth; + break; + } + Act_FormStart (NextAction); + Usr_PutParamOtherUsrCodEncrypted (); + + /* New password */ + Tbl_StartTableCenter (2); + Pwd_PutFormToGetNewPasswordTwice (); + Tbl_EndTable (); + + /* End form */ + Btn_PutConfirmButton (Txt_Change_password); + Act_FormEnd (); + + /***** End box *****/ + Box_EndBox (); } - Act_FormStart (NextAction); - Usr_PutParamOtherUsrCodEncrypted (); - - /* New password */ - Tbl_StartTableCenter (2); - Pwd_PutFormToGetNewPasswordTwice (); - Tbl_EndTable (); - - /* End form */ - Btn_PutConfirmButton (Txt_Change_password); - Act_FormEnd (); - - /***** End box *****/ - Box_EndBox (); + else + Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } - else + else // User not found Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } - else // User not found - Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_); } /*****************************************************************************/ diff --git a/swad_password.h b/swad_password.h index 4adb3aeeb..457981dc2 100644 --- a/swad_password.h +++ b/swad_password.h @@ -49,8 +49,7 @@ bool Pwd_CheckCurrentPassword (void); bool Pwd_CheckPendingPassword (void); void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void); -void Pwd_ActChgMyPwd1 (void); -void Pwd_ActChgMyPwd2 (void); +void Pwd_ActChgMyPwd (void); void Pwd_PutLinkToSendNewPasswd (void); void Pwd_ShowFormSendNewPwd (void); @@ -58,15 +57,14 @@ void Pwd_ChkIdLoginAndSendNewPwd (void); int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]); void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD + 1]); -void Pwd_UpdateOtherPwd1 (void); -void Pwd_UpdateOtherPwd2 (void); +void Pwd_UpdateOtherPwd (void); bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword, const char *EncryptedPassword, long UsrCod); bool Pwd_FastCheckIfPasswordSeemsGood (const char *PlainPassword); -void Pwd_ShowFormChgPwd (void); +void Pwd_ShowFormChgMyPwd (void); void Pwd_PutFormToGetNewPasswordOnce (void); void Pwd_PutFormToGetNewPasswordTwice (void); void Pwd_ShowFormOthPwd (void); diff --git a/swad_text.c b/swad_text.c index a69b4dd0b..2057d9445 100644 --- a/swad_text.c +++ b/swad_text.c @@ -56069,17 +56069,17 @@ const char *Txt_You_have_no_unread_notifications = const char *Txt_You_have_not_banned_any_sender = #if L==1 - "Usted no ha bloqueado ningún remitente."; // Necessita traduccio + "No ha bloqueado ningún remitente."; // Necessita traduccio #elif L==2 "You have not banned any sender."; // Need Übersetzung #elif L==3 "You have not banned any sender."; #elif L==4 - "Usted no ha bloqueado ningún remitente."; + "No ha bloqueado ningún remitente."; #elif L==5 "You have not banned any sender."; // Besoin de traduction #elif L==6 - "Usted no ha bloqueado ningún remitente."; // Okoteve traducción + "No ha bloqueado ningún remitente."; // Okoteve traducción #elif L==7 "You have not banned any sender."; // Bisogno di traduzione #elif L==8 @@ -56132,17 +56132,17 @@ const char *Txt_You_have_not_entered_your_password_correctly = const char *Txt_You_have_not_written_twice_the_same_new_password = #if L==1 - "Usted no ha escrito dos veces la misma contraseña nueva."; // Necessita traduccio + "No ha escrito dos veces la misma contraseña nueva."; // Necessita traduccio #elif L==2 "You have not written twice the same new password."; // Need Übersetzung #elif L==3 "You have not written twice the same new password."; #elif L==4 - "Usted no ha escrito dos veces la misma contraseña nueva."; + "No ha escrito dos veces la misma contraseña nueva."; #elif L==5 "You have not written twice the same new password."; // Besoin de traduction #elif L==6 - "Usted no ha escrito dos veces la misma contraseña nueva."; // Okoteve traducción + "No ha escrito dos veces la misma contraseña nueva."; // Okoteve traducción #elif L==7 "Non hai scritto due volte la stessa password nuova."; #elif L==8