Changed group password

pull/247/head
parent 51fb99f6c5
commit 74d0ffc91c

@ -193,9 +193,11 @@ void on_group_save(GtkWidget *self, dictionary *dict){
int password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->PasswordCombo));
if (password_active == 1) {
password = "!*";
} else if (password_active == 2){
if (password_active == 0){
password = "";
} else if (password_active ==5){
password = " ";
} else if (password_active == 1){
password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
if (yon_char_is_empty(password)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
@ -203,8 +205,25 @@ void on_group_save(GtkWidget *self, dictionary *dict){
yon_ubl_status_highlight_incorrect(window->PasswordEntry);
return;
}
} else {
password="";
} else if (password_active==2){
password = "!*";
} else if (password_active ==3){
password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
if (password[0]!='!') {
char *temp = yon_char_append("!",password);
password=temp;
}
} else if (password_active == 4){
password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)));
if (yon_char_is_empty(password)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->PasswordEntry);
gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0);
return;
}
if (password[0]=='!'){
free(yon_char_divide(password,0));
}
}
final_string = yon_char_unite(yon_char_return_if_exist(group_users,""),
":",yon_char_return_if_exist(gid,"x"),

@ -110,8 +110,12 @@ void yon_interface_update(main_window *widgets){
if (!check_is_password_hash(parameters[5])&&parameters[5][0]!='%'&&parameters[5][1]!='%'){
pars = ENCRYPTED_LABEL;
} else if (!strcmp(parameters[5],"!*")){
} else if (!strcmp(parameters[5]," ")){
pars = NO_PASSWORD_LABEL;
} else if (!strcmp(parameters[5],"!*")){
pars = DENY_LOGIN_LABEL;
} else if (parameters[5][0]=='!'){
pars = BLOCK_LOGIN_LABEL;
} else {
pars = UNENCRYPTED_LABEL;
@ -158,8 +162,12 @@ void yon_interface_update(main_window *widgets){
if (parameters_size>4&&strcmp(parameters[4],"x")&&strcmp(parameters[4],"")){
if (!check_is_password_hash(parameters[4])&&parameters[4][0]!='%'&&parameters[4][1]!='%'){
pars = ENCRYPTED_LABEL;
} else if (!strcmp(parameters[4],"!*")||!strcmp(parameters[4],"*")||!strcmp(parameters[4],"!")){
} else if (!strcmp(parameters[4]," ")){
pars = NO_PASSWORD_LABEL;
} else if (!strcmp(parameters[4],"!*")){
pars = DENY_LOGIN_LABEL;
} else if (parameters[4][0]=='!'){
pars = BLOCK_LOGIN_LABEL;
} else {
pars = UNENCRYPTED_LABEL;
@ -1702,14 +1710,37 @@ void on_main_edit(GtkWidget *, main_window *widgets){
}
}
if (size>4){
if (!yon_char_is_empty(parsed[4])){
if (!strcmp(parsed[4],"!*")||!strcmp(parsed[4],"!")||!strcmp(parsed[4],"*")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),1);
gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),"");
} else if (strcmp(parsed[4],"x")){
gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),parsed[4]);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),2);
if (strcmp(parsed[4]," ")&&!yon_char_check_begins_with(parsed[4],"!")&&!yon_char_check_begins_with(parsed[4],"*")&&!yon_char_check_begins_with(parsed[4],"%%")){
if (check_is_password_hash(parsed[4])){
char *temp = yon_char_append("%%",parsed[4]);
free(parsed[4]);
parsed[4]=temp;
}
}
window->old_password=yon_char_new(parsed[4]);
if (strcmp(parsed[4],"x")&&strcmp(parsed[4],"")){
if (!yon_char_is_empty(parsed[4])){
if (check_is_password_hash(parsed[4])){
if (yon_char_check_begins_with(parsed[4],"%%")==-1){
char *temp = yon_char_append("%%",parsed[4]);
free(parsed[4]);
parsed[4]=temp;
}
}
if (!strcmp(parsed[4],"!*")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),2);
} else if (!strcmp(parsed[4]," ")) {
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),5);
} else if (parsed[4][0]=='!'){
char *password_or = yon_char_new(parsed[4]);
free(yon_char_divide(password_or,0));
gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),password_or);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),3);
free(password_or);
} else {
gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),parsed[4]);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),1);
}
}
}
} else {

@ -307,6 +307,7 @@ typedef struct{
GtkWidget *MainNotebook;
char *last_gid;
char *old_password;
} ubl_settings_usergroups_group_creation_window;
typedef struct{

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface domain="ubl-settings-usergroups">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-usergroups.css -->
@ -353,8 +353,11 @@
<property name="active">0</property>
<items>
<item translatable="yes">Default</item>
<item translatable="yes">No password required</item>
<item translatable="yes">Set a password</item>
<item translatable="yes">Deny login</item>
<item translatable="yes">Block login with password</item>
<item translatable="yes">Unblock login with password</item>
<item translatable="yes">No password required</item>
</items>
</object>
<packing>

Loading…
Cancel
Save