Ejemplo n.º 1
0
    def __on_applybutton_clicked(self, button):
        pass0 = self.pass0_entry.get_text().replace(" ", "")
        pass1 = self.pass1_entry.get_text().replace(" ", "")
        pass2 = self.pass2_entry.get_text().replace(" ", "")

        check = GLib.Checksum(GLib.ChecksumType.SHA256)
        check.update(pass0.encode("utf-8"))
        __oldpass1 = check.get_string()
        __oldpass2 = self.uu.get_user_password(self.user)[0][0]

        if len(pass0) < 6:
            print("Old Password should be at least 6 characters")
            self.change_stat_label(
                self.stat_label,
                "Old Password should be at least 6 characters")
            return
        if len(pass1) < 6:
            print("Enter New Password  at least 6 characters")
            self.change_stat_label(
                self.stat_label, "Enter New Password  at least 6 characters")
            return
        if not pass2:
            print("Enter Retype Password")
            self.change_stat_label(self.stat_label, "Enter Retype Password")
            return
        if pass1 != pass2:
            print("Password not match")
            self.change_stat_label(self.stat_label, "Password not match")
            return
        if __oldpass1 != __oldpass2:
            print("Old Password not match")
            self.change_stat_label(self.stat_label, "Old Password not match")
            return

        check.reset()
        check.update(pass1.encode("utf-8"))
        __pass = check.get_string()
        self.uu.change_user_password(self.user, __pass)

        print("Edit User {} done".format(self.user))
        #self.change_stat_label(self.stat_label,"Edit User {} done".format(self.user))
        self._quit()
Ejemplo n.º 2
0
    def __on_addbutton_clicked(self, button):
        user = self.user_entry.get_text().replace(" ", "")
        pass1 = self.pass1_entry.get_text().replace(" ", "")
        pass2 = self.pass2_entry.get_text().replace(" ", "")
        __admin = 1 if self.isadmin.get_active() else 0

        if not user:
            print("Enter New User")
            self.change_stat_label(self.stat_label, "Enter New User")
            return
        else:
            for i in self.uu.get_all_users():
                if user in i:
                    print("User already exists")
                    self.change_stat_label(self.stat_label,
                                           "User already exists")
                    return

        if len(pass1) < 6:
            print("Enter Password  at least 6 characters")
            self.change_stat_label(self.stat_label,
                                   "Enter Password  at least 6 characters")
            return
        if not pass2:
            print("Enter Retype Password")
            self.change_stat_label(self.stat_label, "Enter Retype Password")
            return
        if pass1 != pass2:
            print("Password not match")
            self.change_stat_label(self.stat_label, "Password not match")
            return

        check = GLib.Checksum(GLib.ChecksumType.SHA256)
        check.update(pass1.encode("utf-8"))
        __pass = check.get_string()

        self.uu.add_user(user, __pass, __admin)

        self.liststore.append([user, self.isadmin.get_active()])

        self._quit()
        print("Add User {} done".format(user))
Ejemplo n.º 3
0
    def thread_on_connect(self, button, parent, user_entry, password_entry,
                          main_label, _user_label, _pass_label, stat_label,
                          user_check_button):
        pass0 = password_entry.get_text().replace(" ", "")
        user_found = False

        GLib.idle_add(stat_label.set_label, self.apply_msg)
        GLib.idle_add(parent.set_sensitive, False)

        uu = UsersConfig(self.user_db)

        _user_ = user_entry.get_text().replace(" ", "")
        if not _user_:
            print("Enter '{} Entry'".format(self._user_label.get_label()))
            self.change_stat_label(
                stat_label,
                "Enter '{} Entry'".format(self._user_label.get_label()))
            GLib.idle_add(parent.set_sensitive, True)
            return
        if not pass0:
            print("Enter '{} Entry'".format(self._pass_label.get_label()))
            self.change_stat_label(
                stat_label,
                "Enter '{} Entry'".format(self._pass_label.get_label()))
            GLib.idle_add(parent.set_sensitive, True)
            return
        for i in uu.get_all_users():
            if _user_ in i:
                user_found = True

        if not user_found:
            print(self.login_faild)
            self.change_stat_label(stat_label, self.login_faild)
            GLib.idle_add(parent.set_sensitive, True)
            return

        check = GLib.Checksum(GLib.ChecksumType.SHA256)
        check.update(pass0.encode("utf-8"))
        __newpass = check.get_string()
        check.reset()

        __oldpass = uu.get_user_password(_user_)[0][0]

        if __oldpass == __newpass:
            conn = self.create_connection(self.remmber_user_name)
            if self.active_remember:
                if not user_check_button.get_active():
                    if conn:
                        with conn:
                            cur = conn.cursor()
                            cur.execute(sql_update_remember_user_table,
                                        ("", 1))
                    else:
                        print("Conenct to {} Faild.".format(
                            self.remmber_user_name))
                else:
                    if conn:
                        with conn:
                            cur = conn.cursor()
                            olduser = user_entry.get_text()
                            cur.execute(sql_update_remember_user_table,
                                        (olduser, 1))
                    else:
                        print("Conenct to {} Faild.".format(
                            self.remmber_user_name))

            #print("Login Success")
            #self.change_stat_label(stat_label,"Login Success")
            #GLib.idle_add(self.destroy)
            GLib.idle_add(self.__on__success, _user_,
                          True if uu.get_user_info(_user_)[-1] == 1 else False)
        else:
            print(self.login_faild)
            self.change_stat_label(stat_label, self.login_faild)
            GLib.idle_add(parent.set_sensitive, True)
        GLib.idle_add(parent.set_sensitive, True)