Beispiel #1
0
def login_page():
    form = LoginForm()
    if form.validate_on_submit():
        username = form.data["username"]
        user = get_login(username)
        if user is not None:
            password = form.data["password"]
            if hasher.verify(password, user.password):
                login_user(user)
                flash("You have successfully logged in as " + username)
                next_page = request.args.get("next", url_for("home_page"))
                return redirect(next_page)
        flash("Invalid credentials.")
    return render_template("login.html", form=form)
Beispiel #2
0
    def __init__(self):
        # Load username and password from file
        self.login_info = get_login()

        self.browser = webdriver.Chrome()
        self.wait = WebDriverWait(self.browser, 60)

        # Tracks if the player dies and we're in the lobby again
        self.dead_state = False
        self.navigate = Navigate(self.browser)
        # Eventually all player actions should be wrapped up in states
        # With the state only being changed under some conditions
        # For now this is the only playerstate we have, so updating it when we
        #   need it is good enough
        self.state = FindDownStaircase(self.browser, self.navigate)
Beispiel #3
0
    def setup():
        # Get login info
        login_info = get_login()

        browser = webdriver.Chrome()
        browser.get(login_info['server'])
        wait = WebDriverWait(browser, 60)
        # Enter username/password
        element = wait.until(EC.element_to_be_clickable((By.ID, 'username')))
        element.send_keys(login_info['username'])
        element = browser.find_element_by_name('password')
        element.send_keys(login_info['password'] + Keys.RETURN)
        # Start playing the latest stable version of crawl
        element = wait.until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT,
                                                        '(Latest Version!)')))
        element.send_keys(Keys.RETURN)
        # Character select
        # Select felid berseker every time, for easier decision making
        # A class titled fg14 means we're in the menu
        # Existance of a game_message means we're already in the game
        wait.until((EC.presence_of_element_located((By.CSS_SELECTOR,
                                                    '.fg14, .game_message'))))
        try:
            if browser.find_element_by_xpath('//*[@id="crt"]/span[1]/span[2]'):
                print "selecting character"
                element = browser.find_element_by_tag_name('html')
                element.send_keys('y')
                wait.until(EC.text_to_be_present_in_element(
                            (By.XPATH, '//*[@id="crt"]/span[1]/span[2]'),
                            'Please select your background.'))
                element = browser.find_element_by_tag_name('html')
                element.send_keys('e')
                # Now that we're logged in wait for the first game message
                wait.until(EC.presence_of_element_located(
                            (By.CLASS_NAME, 'game_message')))
        except selenium.common.exceptions.NoSuchElementException:
            pass
        return browser
Beispiel #4
0
def main():
	# Get JSON
	data = sys.stdin.read()
	data_json = json.loads(data)

	# Get value JSON
	account = data_json['account']
	username = account['username']
	password = account['password']

	# Check login. If it is all right continue reading JSON
	ida = get_login(username, password)
	if (ida > 0):

		# coords = data_json['coords']

		# images = []
		# dates = []

		# images_dict = data_json['images']
		# for image_dict in images_dict:
		# 	image = image_dict['code64']
		# 	images.append(image)
		# 	date = image_dict['date']
		# 	dates.append(date)
		
		# 	# Decode and save image
		# 	save_image(image, date)

		#hunter = Hunter(ida, images, datas, coords)

		# Send response
		send_response(True)
	else:
		# Send response
		send_response(False)
Beispiel #5
0
def main():
    # Get JSON
    data = sys.stdin.read()
    data_json = json.loads(data)

    # Get value JSON
    account = data_json['account']
    username = account['username']
    password = account['password']

    # Check login. If it is all right continue reading JSON
    ida = get_login(username, password)
    if (ida > 0):

        # coords = data_json['coords']

        # images = []
        # dates = []

        # images_dict = data_json['images']
        # for image_dict in images_dict:
        # 	image = image_dict['code64']
        # 	images.append(image)
        # 	date = image_dict['date']
        # 	dates.append(date)

        # 	# Decode and save image
        # 	save_image(image, date)

        #hunter = Hunter(ida, images, datas, coords)

        # Send response
        send_response(True)
    else:
        # Send response
        send_response(False)
Beispiel #6
0
from login import get_login
from search import get_search
from backhome import get_book, get_hash_password, get_txt
from read import get_read_window
import PySimpleGUI as sg
login_window, users, data = get_login()
login_num = 0
while True:
    event, value = login_window.read()
    if event == None or event == 'out':
        break
    elif event == 'user':
        login_window['password'].update(data[users.index(
            value['user'])]['load'])
    elif event == 'in':
        if value['user'] not in users:
            sg.PopupOK('用户未注册')
        else:
            password_hash = get_hash_password(value['password'])
            if password_hash == data[users.index(value['user'])]['password']:
                sg.PopupOK('登录成功!')
                login_num = 1
                break
            else:
                sg.PopupOK('登陆失败!')
login_window.close()
del login_window
if login_num == 1:
    search_window, book_data = get_search()
    while True:
        event, value = search_window.read()
Beispiel #7
0
def main():
    get_login()
    return render_template("home.html")
Beispiel #8
0
def load_user(user_id):
    return get_login(user_id)