Пример #1
0
 def username_validation(self, username):
     if self.credential_validation() and not dm.search_by_name(username):
         return True
     else:
         funcs.clear_entries(self.entries)
         funcs.error_messagebox('Username already in use.')
         return False
Пример #2
0
    def create_user(self):
        newId = dm.create_new_id()
        username = self.usernameEntry.get()
        password = self.passwordEntry.get()

        if self.username_validation(username):
            dm.add_to_database(newId, username, password)
            funcs.clear_entries(self.entries)
            messagebox.showinfo('Success!', 'New user has been created.')
Пример #3
0
    def create_widgets(self):
        # ==== LABELS ====
        tk.Label(
            self,
            text='Please Sign Up',
        ).grid(row=0, columnspan=3, sticky='n')

        tk.Label(self, text='New Username:'******'e')

        tk.Label(self, text='Password:'******'e')

        tk.Label(self, text='Confirm Password:'******'e')

        tk.Label(self, text='Already have an account?').grid(row=5,
                                                             column=0,
                                                             columnspan=2)

        # ==== ENTRIES ====

        #Username Entry
        self.usernameEntry.config(width=15)
        self.usernameEntry.grid(row=1, column=1, columnspan=2)

        #Password Entry
        self.passwordEntry.config(show='*', width=15)
        self.passwordEntry.grid(row=2, column=1, columnspan=2)

        #Password Confirmation Entry
        self.passwordConfirmationEntry.config(
            show='*',
            width=15,
        )
        self.passwordConfirmationEntry.grid(row=3, column=1, columnspan=2)

        entries = [
            self.usernameEntry, self.passwordEntry,
            self.passwordConfirmationEntry
        ]

        # ==== BUTTONS ====
        tk.Button(self, text='Sign Up',
                  command=lambda: self.create_user()).grid(row=4, columnspan=3)

        tk.Button(self,
                  text='Login',
                  command=lambda: [
                      self.controller.change_frame(login.LoginFrame),
                      funcs.clear_entries(entries)
                  ]).grid(row=5, column=2)
Пример #4
0
    def credential_validation(self):
        valid = True
        nonChars = [' ', '~', '+', '^', '*', '(', ')', ':']

        username = self.usernameEntry.get()
        password = self.passwordEntry.get()
        passwordConfirmation = self.passwordConfirmationEntry.get()

        for i in nonChars:
            if (i not in username) and (password == passwordConfirmation):
                valid = True
            else:
                funcs.error_messagebox('''
                Invalid username or password \n 
                P.S: Don\'t use ~ , + , ^ , * , : , ( or ) ''')
                funcs.clear_entries(self.entries)
                valid = False
                break

        return valid