예제 #1
0
    def addFriend(self, AddFriendPopup):
        newFriend = User()

        newFriend.name = self.addFriendOpen.new_friend_name.get()

        if (newFriend.id not in self.currentUser.friends):
            if (userDB.checkAccExistence(newFriend.name, 'username')
                    and newFriend.name !=
                    self.currentUser.name):  #if the account is found, add
                # append to user friends list
                newFriend = userDB.load_user_info(newFriend.name)
                groupID = userDB.create_group_id()

                print("Friend chat ID: %s" % groupID)

                userDB.join_group(groupID, newFriend.name, self.currentUser.id,
                                  'dm')
                userDB.join_group(groupID, self.currentUser.name, newFriend.id,
                                  'dm')

                self.currentUser = userDB.load_user_info(
                    None, self.currentUser.id, 'user_id')
                print("My friends!!!!!!!!!!!!!!!!!!")
                print(self.currentUser.friends)
                AddFriendPopup.friendlabel.config(text="User found!",
                                                  foreground="yellow")
                self.page.updateFriendList(self.currentUser)

                ## UPDATE NEW FRIEND'S LIST IF THEY ARE LOGGED ON
                Client.updateAllGroupMembers(self, self,
                                             self.currentGroup.member_ids)
            else:
                AddFriendPopup.friendlabel.config(text="User not found!",
                                                  foreground="red")
        else:
            AddFriendPopup.friendlabel.config(text="Friend already added!",
                                              foreground="red")
예제 #2
0
    def completeRegClick(self):
        login_user = 0

        if (self.page.Name_entry.get() == ""
                or self.page.Name_entry.get() == "Create a Username"):
            self.page.flabel.config(text="Please enter a username.")
            return

        if (userDB.checkAccExistence(self.page.Name_entry.get(), 'username')):
            self.page.flabel.config(
                text="Username already taken.\nPlease enter a unique username."
            )
            return

        if (self.page.email_entry.get() == ""
                or self.page.email_entry.get() == "Enter Your E-Mail"):
            self.page.flabel.config(text="Please enter an e-mail.")
            return

        if (userDB.check_valid_email(self.page.email_entry.get()) == False):
            self.page.flabel.config(
                text="Invalid e-mail format. Verify your input.")
            return

        if (userDB.check_valid_email(self.page.email_entry.get()) == None):
            self.page.flabel.config(
                text=
                "E-mail already registered. Forgot your\nusername or password? Try the 'Forgot\nusername/password' button on the login page!"
            )
            return

        if (self.page.Pass_entry.get() == ""
                or self.page.Pass_reentry.get() == ""
                or self.page.Pass_entry.get() == "Choose a Password"
                or self.page.Pass_reentry.get() == "Re-Enter Password"):
            self.page.flabel.config(
                text="Please do not leave the\npassword fields blank.")
            return

        if (userDB.check_valid_password(self.page.Pass_entry.get()) == 0):
            self.page.flabel.config(
                text="Password must be at least 7 characters!")
            return

        elif (userDB.check_valid_password(self.page.Pass_entry.get()) == 1):
            self.page.flabel.config(
                text="Password must contain at least (1) digit.")
            return

        elif (userDB.check_valid_password(self.page.Pass_entry.get()) == 2):
            self.page.flabel.config(
                text="Password must contain at least (1)\nuppercase character")
            return

        elif (userDB.check_valid_password(self.page.Pass_entry.get()) == 3):
            self.page.flabel.config(
                text=
                "Password must contain at least (1)\nspecial character(!#$%&'()*+,-./[\\\]^_`{|}~)"
            )
            return

        if (self.page.Pass_entry.get() != self.page.Pass_reentry.get()):
            self.page.flabel.config(text="Passwords do not match!")
            return

        elif (userDB.register_user(self.page.Name_entry.get(),
                                   self.page.Pass_entry.get(),
                                   self.page.email_entry.get()) == True):
            self.page.flabel.config(text="")
            self.switch_page(LoginPage)
            return

        elif (userDB.register_user(self.page.Name_entry.get(),
                                   self.page.Pass_entry.get(),
                                   self.page.email_entry.get()) == False):
            self.page.flabel.config(
                text=
                "User already registered. \nPlease log in using your credentials"
            )
            return
예제 #3
0
    def changeUserAndPass(self, AccSettingsPopup):
        self.accSettingsOpen.errLabel.config(text="", foreground="red")
        self.newuser = ""
        self.newpass = ""
        self.newemail = ""
        self.olduser = self.currentUser.name
        self.oldemail = self.currentUser.email
        self.oldpass = AccSettingsPopup.oldPassEntry.get()
        self.currentID = self.currentUser.id

        #Check for valid password, if it is valid, we can change settings
        if (userDB.login_user(self.currentUser.name, self.oldpass) == 2):
            self.accSettingsOpen.errLabel.config(text="Invalid Password!")
            return
        else:
            # Check new password input
            if AccSettingsPopup.changePasswordInput.get() != "":
                if AccSettingsPopup.confirmPasswordInput.get(
                ) != AccSettingsPopup.changePasswordInput.get():
                    self.accSettingsOpen.errLabel.config(
                        text="New Password does not match confirmation")
                    return
                else:
                    #if new passwords match, set newpass
                    self.newpass = AccSettingsPopup.changePasswordInput.get()
                    self.accSettingsOpen.errLabel.config(
                        text="Settings Changed", foreground="green")
                    userDB.update_user_info(self.newpass, 'password',
                                            self.currentUser.id)
                    self.currentUser = userDB.load_user_info(
                        None, self.currentUser.id, 'user_id')

            # Check new email input
            if AccSettingsPopup.changeEmailInput.get() != "":
                self.newemail = AccSettingsPopup.changeEmailInput.get()

                if (self.newemail == self.oldemail):
                    self.accSettingsOpen.errLabel.config(
                        text="E-Mail unchanged", foreground="yellow")
                if (userDB.check_valid_email(self.newemail) == None):
                    self.accSettingsOpen.errLabel.config(
                        text="E-Mail already registered", foreground="green")
                    return
                elif (userDB.check_valid_email(self.newemail) == True):
                    userDB.update_user_info(self.newemail, 'email',
                                            self.currentUser.id)
                    #self.currentUser = userDB.load_user_info(None, self.currentUser.id[0], 'user_id')
                else:
                    self.accSettingsOpen.errLabel.config(
                        text="Invalid or already registered E-Mail Address.")
                    return

            #Check username input
            if AccSettingsPopup.changeUserNameInput.get() != "":
                self.newuser = AccSettingsPopup.changeUserNameInput.get()

                if (self.newuser == self.olduser):
                    self.accSettingsOpen.errLabel.config(
                        text="Username unchanged", foreground="yellow")
                    return

                if (userDB.checkAccExistence(self.newuser, 'username')
                    ):  #if the new username is already registered
                    self.accSettingsOpen.errLabel.config(
                        text=
                        "Username is already taken.\nPlease choose a different username"
                    )
                    return

                userDB.update_user_info(self.newuser, 'username',
                                        self.currentUser.id, self.olduser)
                self.accSettingsOpen.errLabel.config(text="Settings Changed",
                                                     foreground="green")
                Client.updateAllGroupMembers(self, self,
                                             self.currentUser.friends)

        #Call changes with updated information
        self.currentUser = userDB.load_user_info(None, self.currentUser.id,
                                                 'user_id')