Fixed password change date editing when toggled user deactivation

pull/141/head
parent 7366294c5f
commit 84262a9c62

@ -1757,6 +1757,22 @@ void on_user_save(GtkWidget *self, dictionary *dict){
password="";
}
if (!window->old_password||window->old_password&&strcmp(window->old_password,password)){
time_t t = time(NULL);
struct tm tm = *localtime(&t);
char *month = yon_char_from_int(tm.tm_mon+1);
if (strlen(month)==1){
month=yon_char_append("0",month);
}
char *day = yon_char_from_int(tm.tm_mday);
if (strlen(day)==1){
day=yon_char_append("0",day);
}
password_changed_date = yon_char_unite(yon_char_from_int(1900+tm.tm_year),"-",month,"-",day,NULL);
} else {
password_changed_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordChangedEntry));
}
deactivate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userDeactivatedCheck));
if (deactivate){
if (strlen(password)>1&&password[0]=='%'&&password[1]=='%'){
@ -1853,22 +1869,6 @@ void on_user_save(GtkWidget *self, dictionary *dict){
extra_options=(char*)gtk_entry_get_text(GTK_ENTRY(window->userExtraOptionsEntry));
if (!window->old_password||window->old_password&&strcmp(window->old_password,password)){
time_t t = time(NULL);
struct tm tm = *localtime(&t);
char *month = yon_char_from_int(tm.tm_mon+1);
if (strlen(month)==1){
month=yon_char_append("0",month);
}
char *day = yon_char_from_int(tm.tm_mday);
if (strlen(day)==1){
day=yon_char_append("0",day);
}
password_changed_date = yon_char_unite(yon_char_from_int(1900+tm.tm_year),"-",month,"-",day,NULL);
} else {
password_changed_date = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordChangedEntry));
}
int force_at_next_login_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userForceChangeCheck));
if (force_at_next_login_active){
password_changed_date = "0";
@ -2347,7 +2347,10 @@ void on_main_edit(GtkWidget *self, main_window *widgets){
}
}
if (parsed_size>5){
window->old_password=parameters[5];
window->old_password=yon_char_new(parameters[5]);
if (!yon_char_is_empty(window->old_password)&&strlen(window->old_password)&&window->old_password[0]=='!'&&window->old_password[1]=='*'){
free(yon_char_divide(window->old_password,1));
}
if (strcmp(parameters[5],"x")&&strcmp(parameters[5],"")){
if (strstr(parameters[5],"!*")){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userDeactivatedCheck),1);

Loading…
Cancel
Save