mirror of https://github.com/acanas/swad-core.git
Version 18.5
This commit is contained in:
parent
771d77048d
commit
0f5a09af56
97
swad_ID.c
97
swad_ID.c
|
@ -502,51 +502,6 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
|
|||
Act_EndForm ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show form to the change of IDs of another user ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void ID_ShowFormOthIDs (void)
|
||||
{
|
||||
extern const char *Txt_ID;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
|
||||
/***** Get user whose password must be changed *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** Start box *****/
|
||||
Box_StartBox (NULL,Txt_ID,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Show user's record *****/
|
||||
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,
|
||||
&Gbl.Usrs.Other.UsrDat,NULL);
|
||||
|
||||
/***** Form with the user's ID *****/
|
||||
ID_ShowFormChangeOtherUsrID ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = ID_ID_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
}
|
||||
else // User not found
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = ID_ID_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Show form to change my user's ID ********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -800,23 +755,23 @@ void ID_RemoveOtherUsrID (void)
|
|||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
/***** Remove user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** Remove user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
ID_RemoveUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
|
||||
/***** Update list of IDs *****/
|
||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||
/***** Update list of IDs *****/
|
||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
}
|
||||
else
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
else // User not found
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = ID_ID_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -932,23 +887,23 @@ void ID_NewOtherUsrID (void)
|
|||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
/***** New user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
ID_NewUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** New user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
ID_NewUsrID (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
|
||||
/***** Update list of IDs *****/
|
||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||
/***** Update list of IDs *****/
|
||||
ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
}
|
||||
else
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
else // User not found
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = ID_ID_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -72,7 +72,6 @@ bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID);
|
|||
void ID_WriteUsrIDs (struct UsrData *UsrDat,const char *Anchor);
|
||||
bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat);
|
||||
|
||||
void ID_ShowFormOthIDs (void);
|
||||
void ID_ShowFormChangeMyID (bool IShouldFillID);
|
||||
void ID_ShowFormChangeOtherUsrID (void);
|
||||
|
||||
|
|
|
@ -2796,9 +2796,9 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActNewID_Std */{1454,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ID_NewOtherUsrID ,NULL},
|
||||
/* ActNewID_Tch */{1455,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ID_NewOtherUsrID ,NULL},
|
||||
|
||||
/* ActChgPwdOth */{1467,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
/* ActChgPwdStd */{1468,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
/* ActChgPwdTch */{1469,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
/* ActChgPwdOth */{1467,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherUsrPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
/* ActChgPwdStd */{1468,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherUsrPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
/* ActChgPwdTch */{1469,-1,TabUnk,ActLstTch ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateOtherUsrPwd ,Acc_ShowFormChgOtherUsrAccount ,NULL},
|
||||
|
||||
/* ActRemMaiOth */{1478,-1,TabUnk,ActLstOth ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mai_RemoveOtherUsrEmail ,NULL},
|
||||
/* ActRemMaiStd */{1479,-1,TabUnk,ActLstStd ,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mai_RemoveOtherUsrEmail ,NULL},
|
||||
|
@ -3136,7 +3136,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* 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 ,Acc_ShowFormChgMyAccount ,NULL},
|
||||
/* ActChgPwd */{ 35,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_ActChgMyPwd ,Acc_ShowFormChgMyAccount ,NULL},
|
||||
/* ActChgPwd */{ 35,-1,TabUnk,ActFrmMyAcc ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,Pwd_UpdateMyPwd ,Acc_ShowFormChgMyAccount ,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},
|
||||
|
|
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.5 (2018-10-16)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.5.1 (2018-10-16)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.5.1: Oct 16, 2018 Code refactoring related to edition. of another user's account. (235212 lines)
|
||||
Version 18.5: Oct 16, 2018 Changes in management of other users. (235292 lines)
|
||||
19 changes necessary in database:
|
||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1735','es','N','Administrar cuenta otro');
|
||||
|
|
63
swad_mail.c
63
swad_mail.c
|
@ -1138,41 +1138,6 @@ long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
|||
return UsrCod;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Show form to the change the email of another user ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mai_ShowFormOthEmail (void)
|
||||
{
|
||||
extern const char *Txt_Email;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
|
||||
/***** Get user whose password must be changed *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** Start box *****/
|
||||
Box_StartBox (NULL,Txt_Email,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Show user's record *****/
|
||||
Rec_ShowSharedUsrRecord (Rec_SHA_RECORD_LIST,
|
||||
&Gbl.Usrs.Other.UsrDat,NULL);
|
||||
|
||||
/***** Form with the user's email *****/
|
||||
Mai_ShowFormChangeOtherUsrEmail ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
}
|
||||
else
|
||||
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_);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Show form to change my email ************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1461,11 +1426,16 @@ void Mai_RemoveOtherUsrEmail (void)
|
|||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
/***** Remove user's email *****/
|
||||
Mai_RemoveEmail (&Gbl.Usrs.Other.UsrDat);
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** Remove user's email *****/
|
||||
Mai_RemoveEmail (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
}
|
||||
else
|
||||
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_);
|
||||
|
@ -1546,12 +1516,17 @@ void Mai_NewOtherUsrEmail (void)
|
|||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
/***** New user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Mai_NewUsrEmail (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** New user's ID *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
Mai_NewUsrEmail (&Gbl.Usrs.Other.UsrDat,ItsMe);
|
||||
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
/***** Show form again *****/
|
||||
Acc_ShowFormChgOtherUsrAccount ();
|
||||
}
|
||||
else
|
||||
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_);
|
||||
|
|
|
@ -77,7 +77,6 @@ bool Mai_CheckIfEmailIsValid (const char *Email);
|
|||
bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat);
|
||||
long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1]);
|
||||
|
||||
void Mai_ShowFormOthEmail (void);
|
||||
void Mai_ShowFormChangeMyEmail (bool IMustFillEmail,bool IShouldConfirmEmail);
|
||||
void Mai_ShowFormChangeOtherUsrEmail (void);
|
||||
|
||||
|
|
219
swad_password.c
219
swad_password.c
|
@ -157,10 +157,10 @@ void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Change my password in database **********************/
|
||||
/*********************** Update my password in database **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Pwd_ActChgMyPwd (void)
|
||||
void Pwd_UpdateMyPwd (void)
|
||||
{
|
||||
extern const char *Txt_You_have_not_written_twice_the_same_new_password;
|
||||
extern const char *Txt_Your_password_has_been_changed_successfully;
|
||||
|
@ -218,6 +218,60 @@ void Pwd_ActChgMyPwd (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Update another user's password ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Pwd_UpdateOtherUsrPwd (void)
|
||||
{
|
||||
extern const char *Txt_You_have_not_written_twice_the_same_new_password;
|
||||
extern const char *Txt_The_password_has_been_changed_successfully;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
char NewPlainPassword[2][Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
|
||||
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
||||
|
||||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
Par_GetParToText ("Paswd1",NewPlainPassword[0],Pwd_MAX_BYTES_PLAIN_PASSWORD);
|
||||
Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_BYTES_PLAIN_PASSWORD);
|
||||
|
||||
if (strcmp (NewPlainPassword[0],NewPlainPassword[1]))
|
||||
{
|
||||
// Paswords don't match
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
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,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod)) // New password is good?
|
||||
{
|
||||
/* Update other user's data */
|
||||
Str_Copy (Gbl.Usrs.Other.UsrDat.Password,NewEncryptedPassword,
|
||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
||||
Enr_UpdateUsrData (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
Gbl.Alert.Type = Ale_SUCCESS;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_The_password_has_been_changed_successfully);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
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_);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Show form to send a new password by email *******************/
|
||||
/*****************************************************************************/
|
||||
|
@ -383,7 +437,8 @@ void Pwd_ChkIdLoginAndSendNewPwd (void)
|
|||
else // ListUsrCods.NumUsrs > 1
|
||||
{
|
||||
/***** Help message *****/
|
||||
// TODO: This message allows to know if a ID exists in database (when no unique). This should be hidden!
|
||||
// TODO: This message allows to know if a ID exists in database (when no unique).
|
||||
// This should be hidden!
|
||||
sprintf (Gbl.Alert.Txt,Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email,
|
||||
Gbl.Usrs.Me.UsrIdLogin);
|
||||
Ale_ShowAlert (Ale_WARNING,Gbl.Alert.Txt);
|
||||
|
@ -493,70 +548,6 @@ void Pwd_SetMyPendingPassword (char PlainPassword[Pwd_MAX_BYTES_PLAIN_PASSWORD +
|
|||
DB_QueryREPLACE (Query,"can not create pending password");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Update password ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Pwd_UpdateOtherPwd (void)
|
||||
{
|
||||
extern const char *Txt_You_have_not_written_twice_the_same_new_password;
|
||||
extern const char *Txt_The_password_has_been_changed_successfully;
|
||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||
char NewPlainPassword[2][Pwd_MAX_BYTES_PLAIN_PASSWORD + 1];
|
||||
char NewEncryptedPassword[Pwd_BYTES_ENCRYPTED_PASSWORD + 1];
|
||||
|
||||
/***** Get other user's code from form and get user's data *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
{
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
Par_GetParToText ("Paswd1",NewPlainPassword[0],Pwd_MAX_BYTES_PLAIN_PASSWORD);
|
||||
Par_GetParToText ("Paswd2",NewPlainPassword[1],Pwd_MAX_BYTES_PLAIN_PASSWORD);
|
||||
|
||||
if (strcmp (NewPlainPassword[0],NewPlainPassword[1]))
|
||||
{
|
||||
// Paswords don't match
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
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,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod)) // New password is good?
|
||||
{
|
||||
/* Update other user's data */
|
||||
Str_Copy (Gbl.Usrs.Other.UsrDat.Password,NewEncryptedPassword,
|
||||
Pwd_BYTES_ENCRYPTED_PASSWORD);
|
||||
Enr_UpdateUsrData (&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
Gbl.Alert.Type = Ale_SUCCESS;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_The_password_has_been_changed_successfully);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
}
|
||||
else // User not found
|
||||
{
|
||||
Gbl.Alert.Type = Ale_WARNING;
|
||||
Gbl.Alert.Section = Pwd_PASSWORD_SECTION_ID;
|
||||
sprintf (Gbl.Alert.Txt,"%s",
|
||||
Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Check if a password is good ************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -853,63 +844,51 @@ void Pwd_ShowFormChgOtherUsrPwd (void)
|
|||
{
|
||||
extern const char *Txt_Password;
|
||||
extern const char *Txt_Change_password;
|
||||
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 ())
|
||||
/***** Start box *****/
|
||||
Box_StartBox (NULL,Txt_Password,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Start section *****/
|
||||
Lay_StartSection (Pwd_PASSWORD_SECTION_ID);
|
||||
|
||||
/***** Show possible alert *****/
|
||||
if (Gbl.Alert.Section == (const char *) Pwd_PASSWORD_SECTION_ID)
|
||||
Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
|
||||
|
||||
/***** Form to change password *****/
|
||||
/* Start form */
|
||||
switch (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs.Role)
|
||||
{
|
||||
if (Usr_ICanEditOtherUsr (&Gbl.Usrs.Other.UsrDat))
|
||||
{
|
||||
/***** Start box *****/
|
||||
Box_StartBox (NULL,Txt_Password,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Start section *****/
|
||||
Lay_StartSection (Pwd_PASSWORD_SECTION_ID);
|
||||
|
||||
/***** Show possible alert *****/
|
||||
if (Gbl.Alert.Section == (const char *) Pwd_PASSWORD_SECTION_ID)
|
||||
Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
|
||||
|
||||
/***** 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_StartFormAnchor (NextAction,Pwd_PASSWORD_SECTION_ID);
|
||||
Usr_PutParamOtherUsrCodEncrypted ();
|
||||
|
||||
/* New password */
|
||||
Tbl_StartTableWide (2);
|
||||
Pwd_PutFormToGetNewPasswordTwice ();
|
||||
Tbl_EndTable ();
|
||||
|
||||
/* End form */
|
||||
Btn_PutConfirmButton (Txt_Change_password);
|
||||
Act_EndForm ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
|
||||
/***** End section *****/
|
||||
Lay_EndSection ();
|
||||
}
|
||||
else
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
case Rol_STD:
|
||||
NextAction = ActChgPwdStd;
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
NextAction = ActChgPwdTch;
|
||||
break;
|
||||
default: // Guest, user or admin
|
||||
NextAction = ActChgPwdOth;
|
||||
break;
|
||||
}
|
||||
else // User not found
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
Act_StartFormAnchor (NextAction,Pwd_PASSWORD_SECTION_ID);
|
||||
Usr_PutParamOtherUsrCodEncrypted ();
|
||||
|
||||
/* New password */
|
||||
Tbl_StartTableWide (2);
|
||||
Pwd_PutFormToGetNewPasswordTwice ();
|
||||
Tbl_EndTable ();
|
||||
|
||||
/* End form */
|
||||
Btn_PutConfirmButton (Txt_Change_password);
|
||||
Act_EndForm ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
|
||||
/***** End section *****/
|
||||
Lay_EndSection ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -49,7 +49,8 @@ bool Pwd_CheckCurrentPassword (void);
|
|||
bool Pwd_CheckPendingPassword (void);
|
||||
void Pwd_AssignMyPendingPasswordToMyCurrentPassword (void);
|
||||
|
||||
void Pwd_ActChgMyPwd (void);
|
||||
void Pwd_UpdateMyPwd (void);
|
||||
void Pwd_UpdateOtherUsrPwd (void);
|
||||
|
||||
void Pwd_PutLinkToSendNewPasswd (void);
|
||||
void Pwd_ShowFormSendNewPwd (void);
|
||||
|
@ -57,8 +58,6 @@ 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_UpdateOtherPwd (void);
|
||||
|
||||
bool Pwd_SlowCheckIfPasswordIsGood (const char *PlainPassword,
|
||||
const char *EncryptedPassword,
|
||||
long UsrCod);
|
||||
|
|
Loading…
Reference in New Issue