Esempio n. 1
0
def UserDelete(UserID, Password, ConfirmPassword):

    # Is the form empty? Return no error...
    if not UserID and not Password and not ConfirmPassword:
        return ""

        # Do these user passwords match?
    if Password != ConfirmPassword:
        return "Error: Passwords do not match!"

        # Get existing user
    ExistingUsers = Session.query(UsersTable).filter(UsersTable.UserID == UserID).all()
    if len(ExistingUsers) <= 0:
        return "Error: User name does not exist."
    ExistingUser = ExistingUsers[0]

    # Is the given password the active password?
    ExistingHash = __GeneratePasswordHash(Password)
    if ExistingUser.UserPassword != ExistingHash:
        return "Error: Given password is not correct."

        # Delete user from users table
    Session.delete(ExistingUser)
    Session.commit()

    # Logout user
    UserLogout()

    # Done!
    return "deleted"
Esempio n. 2
0
def UserDelete(UserID, Password, ConfirmPassword):
	
	# Is the form empty? Return no error...
	if not UserID and not Password and not ConfirmPassword:
		return ""
	
	# Do these user passwords match?
	if Password != ConfirmPassword:
		return "Error: Passwords do not match!"
	
	# Get existing user
	ExistingUsers = Session.query(UsersTable).filter(UsersTable.UserID == UserID).all()
	if len(ExistingUsers) <= 0:
		return "Error: User name does not exist."
	ExistingUser = ExistingUsers[0]
	
	# Is the given password the active password?
	ExistingHash = __GeneratePasswordHash(Password)
	if ExistingUser.UserPassword != ExistingHash:
		return "Error: Given password is not correct."
	
	# Delete user from users table
	Session.delete(ExistingUser)
	Session.commit()
	
	# Logout user
	UserLogout()
	
	# Done!
	return "deleted"