示例#1
0
    def login(self):
        login = self.logEntry.get()
        password = self.passwordEntry.get()

        if '' in (login, password):
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['fill_all_entries'])
            Window.delete_entries(self.passwordEntry)
            return

        log_in_db = DbManager.get_column_values('Users', 'login')

        if login not in log_in_db:
            messagebox.showerror(
                lp[self.language]['error'],
                lp[self.language]['incorrect_login'].format(login=login))
            Window.delete_entries(self.logEntry, self.passwordEntry)
            return

        if password != DbManager.get_column_value_where(
                'Users', 'password', 'login', login):
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['incorrect_password'])
            Window.delete_entries(self.passwordEntry)
            return

        self.user = {
            'id':
            DbManager.get_column_value_where('Users', 'id', 'login', login),
            'login':
            login,
            'password':
            password,
            'email':
            DbManager.get_column_value_where('Users', 'email', 'login', login),
            'pin':
            DbManager.get_column_value_where('Users', 'pin', 'login', login)
        }

        MailManager.send_mail(self.language,
                              self.user['email'],
                              msg_type='alert',
                              data=login)
        self.root.destroy()

        main_window = MainWindow(self.language, self.user)
        main_window.root.mainloop()
示例#2
0
    def check_pin(self, pin, btn):
        if pin.get() != DbManager.get_column_value_where(
                'Users', 'pin', 'id', self.user['id']):
            messagebox.showerror('Error', 'Invalid PIN.')
            pin.delete(0, 'end')
            return
        btn['btn'].destroy()
        pin.destroy()

        password = tk.Label(self.scrollframe.viewPort,
                            text=DbManager.get_column_value_where(
                                'Accounts', 'password', 'id', btn['acc_id']),
                            bg=self.bg_color)
        password.grid(row=btn['y'], column=3)

        # % same here, adding shown password label to accountsRowsWidgets eliminates the bug
        self.accountsRowsWidgets.append({'shown_password': password})
示例#3
0
    def remind_password(self):
        login = self.widgetsForEntries[1].get()
        email = self.widgetsForEntries[3].get()

        if '' in (login, email):
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['fill_all_entries'])
            return

        if not re.match(r'[^@]+@[^@]+\.[^@]+', email):
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['invalid_email'])
            return

        log_in_db = DbManager.get_column_values('Users', 'login')

        if login not in log_in_db:
            messagebox.showerror(
                lp[self.language]['error'],
                lp[self.language]['incorrect_login'].format(login=login))
            return

        if email != DbManager.get_column_value_where('Users', 'email', 'login',
                                                     login):
            messagebox.showerror(
                lp[self.language]['error'],
                lp[self.language]['email_doesnt_match'].format(email=email))
            return

        password = DbManager.get_column_value_where('Users', 'password',
                                                    'login', login)

        if MailManager.send_mail(self.language,
                                 email,
                                 msg_type='password_request',
                                 data=password,
                                 data2=login):
            messagebox.showinfo(
                lp[self.language]['password_reminder_req'],
                lp[self.language]['password_reminder_accepted'])
        Window.close_top_level(self, self.btnsToDisable)
示例#4
0
 def load_account_data(self, acc_id):
     self.accTitleEntry.insert(
         0,
         DbManager.get_column_value_where('Accounts', 'title', 'id',
                                          acc_id))
     self.loginEntry.insert(
         0,
         DbManager.get_column_value_where('Accounts', 'login', 'id',
                                          acc_id))
     self.associatedEmailEntry.insert(
         0,
         DbManager.get_column_value_where('Accounts', 'associated_email',
                                          'id', acc_id))
     self.passwordEntry.insert(
         0,
         DbManager.get_column_value_where('Accounts', 'password', 'id',
                                          acc_id))
     self.passwordConfirmEntry.insert(
         0,
         DbManager.get_column_value_where('Accounts', 'password', 'id',
                                          acc_id))
     self.accId = acc_id
示例#5
0
    def export(self):
        pin = self.widgetsForEntries[1].get()
        password = self.widgetsForEntries[3].get()

        if not (pin and password):
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['pin_and_password_req'])
            Window.delete_entries(self.widgetsForEntries[1],
                                  self.widgetsForEntries[3])
            return

        if pin == DbManager.get_column_value_where('Users', 'pin', 'id', self.user['id']) \
                and password == DbManager.get_column_value_where('Users', 'password', 'id', self.user['id']):
            Window.close_top_level(self, self.btnsToDisable)

            path = filedialog.askdirectory()
            path += '/exported_accounts.txt'

            accounts = DbManager.get_user_accounts(self.user['id'])

            try:
                with open(path, 'w') as file:
                    for account in accounts:
                        row = 'title: ' + account['title'] + '\tlogin: '******'login'] + '\tassociated email: ' + \
                              account['associated_email'] + '\tpassword: '******'password'] + '\n'
                        file.write(row)
                messagebox.showinfo(lp[self.language]['data_exported'],
                                    lp[self.language]['data_exported_info'])

            except PermissionError:
                pass
        else:
            messagebox.showerror(lp[self.language]['error'],
                                 lp[self.language]['pin_or_password_invalid'])
            Window.delete_entries(self.widgetsForEntries[1],
                                  self.widgetsForEntries[3])
示例#6
0
    def add_account(self):
        validation_result = self.validation()

        if validation_result:
            title = validation_result[0]
            login = validation_result[1]
            associated_email = validation_result[2]
            password = validation_result[3]

            user_id = DbManager.get_column_value_where('Users', 'id', 'login',
                                                       self.user['login'])
            DbManager.insert(
                'Accounts',
                'title, login, associated_email, password, user_id',
                (title, login, associated_email, password, user_id))

            self.refreshAccountListMethod()
            Window.close_top_level(self, self.toDisable)
示例#7
0
    def save_new_security(self):
        old_security = self.oldSecurityEntry.get()
        new_security = self.newSecurityEntry.get()
        confirm_security = self.confirmSecurityEntry.get()

        if not (old_security and new_security and confirm_security):
            messagebox.showerror('Error', 'All fields required.')
            Window.delete_entries(self.oldSecurityEntry, self.newSecurityEntry,
                                  self.confirmSecurityEntry)
            return

        if old_security != DbManager.get_column_value_where(
                'Users', self.mode, 'id', self.user["id"]):
            messagebox.showerror('Error', 'Invalid old PIN.')
            Window.delete_entries(self.oldSecurityEntry, self.newSecurityEntry,
                                  self.confirmSecurityEntry)
            return

        if self.mode == 'password':
            if len(new_security) < 8:  # minimum password length
                messagebox.showerror(
                    'Error', 'Password must be at least 8 characters long.')
                Window.delete_entries(self.oldSecurityEntry,
                                      self.newSecurityEntry,
                                      self.confirmSecurityEntry)
                return

        if new_security != confirm_security:
            messagebox.showerror(
                'Error',
                '\'New password\' and \'Confirm password\' entries don\'t match.'
            )
            Window.delete_entries(self.oldSecurityEntry, self.newSecurityEntry,
                                  self.confirmSecurityEntry)
            return

        DbManager.update('Users', self.mode, new_security, 'id',
                         self.user['id'])  # mode is pwd or pin
        messagebox.showinfo(
            'Success',
            f'Your {self.mode} has been successfully changed.\nRemember not to share it '
            'with anyone else.')
        self.master.user[self.mode] = new_security  # update user
        Window.close_top_level(self, self.master.toDisable)
示例#8
0
    def validation(self):
        title = self.accTitleEntry.get()
        login = self.loginEntry.get()
        associated_email = self.associatedEmailEntry.get()
        password = self.passwordEntry.get()
        password_confirm = self.passwordConfirmEntry.get()
        pin = self.pinEntry.get()

        if not (login or associated_email):
            Window.delete_entries(self.passwordEntry,
                                  self.passwordConfirmEntry, self.pinEntry)
            messagebox.showerror(
                'Error', 'Only login or associated email may remain empty.')
            return None

        if not (title and password):
            Window.delete_entries(self.passwordEntry,
                                  self.passwordConfirmEntry, self.pinEntry)
            messagebox.showerror('Error', 'Title and password are required.')
            return None

        if password != password_confirm:
            Window.delete_entries(self.passwordEntry,
                                  self.passwordConfirmEntry, self.pinEntry)
            messagebox.showerror(
                'Error', 'Password and password confirmation don\'t match.')
            return None

        if associated_email:
            if not re.match(r'[^@]+@[^@]+\.[^@]+', associated_email):
                Window.delete_entries(self.passwordEntry,
                                      self.passwordConfirmEntry,
                                      self.associatedEmailEntry, self.pinEntry)
                messagebox.showerror('Error', 'Invalid email.')
                return None

        if self.mode == 'Edit' and pin != DbManager.get_column_value_where(
                'Users', 'pin', 'id', self.user['id']):
            Window.delete_entries(self.pinEntry)
            messagebox.showerror('Error', 'Invalid PIN.')
            return None

        return title, login, associated_email, password,