diff --git a/swad_ID.c b/swad_ID.c index ad96d940f..29b3286c8 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -439,7 +439,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) case Rol_CTR_ADM: case Rol_INS_ADM: case Rol_SYS_ADM: - return Usr_AsAdminICanEditOtherUsr (UsrDat); + return Usr_ICanEditOtherUsr (UsrDat); default: return false; } @@ -519,7 +519,7 @@ void ID_ShowFormOthIDs (void) /***** Get user whose password must be changed *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - if (Usr_AsAdminICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_ID,NULL,NULL); @@ -723,7 +723,7 @@ static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe) char UsrID[ID_MAX_LENGTH_USR_ID + 1]; bool ICanRemove; - if (Usr_AsAdminICanEditOtherUsr (UsrDat)) + if (Usr_ICanEditOtherUsr (UsrDat)) { /***** Get user's ID from form *****/ Par_GetParToText ("UsrID",UsrID,ID_MAX_LENGTH_USR_ID); @@ -844,7 +844,7 @@ static void ID_NewUsrID (const struct UsrData *UsrDat,bool ItsMe) unsigned NumIDFound = 0; // Initialized to avoid warning bool Error = false; - if (Usr_AsAdminICanEditOtherUsr (UsrDat)) + if (Usr_ICanEditOtherUsr (UsrDat)) { /***** Get new user's ID from form *****/ Par_GetParToText ("NewID",NewID,ID_MAX_LENGTH_USR_ID); diff --git a/swad_account.c b/swad_account.c index 4896635e5..246311ea0 100644 --- a/swad_account.c +++ b/swad_account.c @@ -674,8 +674,6 @@ static bool Acc_GetParamsNewAccount (char NewNicknameWithoutArroba[Nck_MAX_BYTES /***** Step 3/3: Get new password from form *****/ Par_GetParToText ("Paswd",NewPlainPassword,Pwd_MAX_LENGTH_PLAIN_PASSWORD); - Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, - NewPlainPassword,Pwd_MAX_LENGTH_PLAIN_PASSWORD,true); Cry_EncryptSHA512Base64 (NewPlainPassword,NewEncryptedPassword); if (!Pwd_SlowCheckIfPasswordIsGood (NewPlainPassword,NewEncryptedPassword,-1L)) // New password is good? { diff --git a/swad_changelog.h b/swad_changelog.h index 8a433133f..aa114c8d0 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -191,13 +191,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.127.1 (2017-01-28)" +#define Log_PLATFORM_VERSION "SWAD 16.127.3 (2017-01-28)" #define CSS_FILE "swad16.123.css" #define JS_FILE "swad16.123.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.127.3: Jan 28, 2017 Fixed bug in permissions to change another user's data. (212127 lines) + Version 16.127.2: Jan 28, 2017 Fixed bug creating a new account. (212124 lines) Version 16.127.1: Jan 28, 2017 Fixed bug in listing of users. (212125 lines) Version 16.127: Jan 28, 2017 Code refactoring. (212118 lines) Version 16.126.6: Jan 27, 2017 Fixed bug related with list of students. (212098 lines) diff --git a/swad_enrollment.c b/swad_enrollment.c index 34ba3d1e0..9d8ed5c36 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -3154,7 +3154,7 @@ static void Enr_ShowFormToEditOtherUsr (void) /***** Buttons for edition *****/ fprintf (Gbl.F.Out,"
"); - if (Usr_AsAdminICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { Pwd_PutLinkToChangeOtherUsrPassword (); // Put link (form) to change user's password Mai_PutLinkToChangeOtherUsrEmails (); // Put link (form) to change user's emails diff --git a/swad_mail.c b/swad_mail.c index 64ba1c254..13182e605 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -1150,7 +1150,7 @@ void Mai_ShowFormOthEmail (void) /***** Get user whose password must be changed *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - if (Usr_AsAdminICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_Email,NULL,NULL); @@ -1369,7 +1369,7 @@ static void Mai_RemoveEmail (struct UsrData *UsrDat) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; char Email[Usr_MAX_BYTES_USR_EMAIL + 1]; - if (Usr_AsAdminICanEditOtherUsr (UsrDat)) + if (Usr_ICanEditOtherUsr (UsrDat)) { /***** Get new email from form *****/ Par_GetParToText ("Email",Email,Usr_MAX_BYTES_USR_EMAIL); @@ -1451,7 +1451,7 @@ static void Mai_NewUsrEmail (struct UsrData *UsrDat,bool ItsMe) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; char NewEmail[Usr_MAX_BYTES_USR_EMAIL + 1]; - if (Usr_AsAdminICanEditOtherUsr (UsrDat)) + if (Usr_ICanEditOtherUsr (UsrDat)) { /***** Get new email from form *****/ Par_GetParToText ("NewEmail",NewEmail,Usr_MAX_BYTES_USR_EMAIL); diff --git a/swad_password.c b/swad_password.c index 543effa8e..a32132cae 100644 --- a/swad_password.c +++ b/swad_password.c @@ -491,7 +491,7 @@ void Pwd_UpdateOtherPwd1 (void) /***** Get other user's code from form and get user's data *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - if (Usr_AsAdminICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { Par_GetParToText ("Paswd1",NewPlainPassword[0],Pwd_MAX_LENGTH_PLAIN_PASSWORD); Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_LENGTH_PLAIN_PASSWORD); @@ -813,7 +813,7 @@ void Pwd_ShowFormOthPwd (void) /***** Get user whose password must be changed *****/ if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) { - if (Usr_AsAdminICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) + if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat)) { /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_Password,NULL,NULL); diff --git a/swad_photo.c b/swad_photo.c index e1b33dbde..fcacf3a81 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -150,7 +150,7 @@ bool Pho_ICanChangeOtherUsrPhoto (const struct UsrData *UsrDat) case Rol_CTR_ADM: case Rol_INS_ADM: case Rol_SYS_ADM: - return Usr_AsAdminICanEditOtherUsr (UsrDat); + return Usr_ICanEditOtherUsr (UsrDat); default: return false; } diff --git a/swad_user.c b/swad_user.c index abc3ed45e..689ad257e 100644 --- a/swad_user.c +++ b/swad_user.c @@ -847,18 +847,21 @@ bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat) case Rol_CTR_ADM: case Rol_INS_ADM: case Rol_SYS_ADM: - return Usr_AsAdminICanEditOtherUsr (UsrDat); + return Usr_ICanEditOtherUsr (UsrDat); default: return false; } } /*****************************************************************************/ -/************ Check if I (as admin) can edit another user's data *************/ +/***************** Check if I can edit another user's data *******************/ /*****************************************************************************/ -bool Usr_AsAdminICanEditOtherUsr (const struct UsrData *UsrDat) +bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat) { + if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me + return true; + switch (Gbl.Usrs.Me.LoggedRole) { case Rol_DEG_ADM: diff --git a/swad_user.h b/swad_user.h index aa2deec33..e6ae5c679 100644 --- a/swad_user.h +++ b/swad_user.h @@ -235,7 +235,7 @@ bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod); bool Usr_CheckIfUsrIsSuperuser (long UsrCod); bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat); -bool Usr_AsAdminICanEditOtherUsr (const struct UsrData *UsrDat); +bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat); unsigned Usr_GetNumCrssOfUsr (long UsrCod); unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod);