Compare commits
No commits in common. "594a078515509d8aa0ec5d056068dd77845af439" and "7e8868eb5c66509c27283d2fb9cf7d50d13388c4" have entirely different histories.
594a078515
...
7e8868eb5c
3 changed files with 19 additions and 67 deletions
|
@ -1,18 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Curious Greg - Curious Cat Connection</title>
|
|
||||||
{% include 'imports.html' %}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Connect to Curious Cat</h1>
|
|
||||||
<h2>A question containing a challenge code has been submitted to your Curious Cat inbox. Please paste that code here.</h2>
|
|
||||||
<!-- <div id='logo-main'></div> -->
|
|
||||||
<form action='/internal/ccc_c' method='POST'>
|
|
||||||
<label for='challenge'>Response code</label><br />
|
|
||||||
<input name='challenge' type='number' required pattern='\d{6}' placeholder='123456'></input><br />
|
|
||||||
<button>Continue</button>
|
|
||||||
</div>
|
|
||||||
{% include 'footer.html' %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,17 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Curious Greg - Curious Cat Connection</title>
|
|
||||||
{% include 'imports.html' %}
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Connected to Curious Cat</h1>
|
|
||||||
<h2>Your Curious Cat profile has been connected.</h2>
|
|
||||||
<div id='question'>
|
|
||||||
<div id='form-avi' style={{ bg }}></div>
|
|
||||||
<div id='form-avi-label'>{{ session['cc'] }}</div><br />
|
|
||||||
<a href='/home'>Continue</a>
|
|
||||||
</div>
|
|
||||||
{% include 'footer.html' %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
51
web.py
51
web.py
|
@ -23,23 +23,24 @@ db = mysql.connector.connect(user=cfg['dbuser'], password=cfg['dbpass'], databas
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
dc = db.cursor(dictionary=True)
|
dc = db.cursor(dictionary=True)
|
||||||
# MariaDB [curiousgreg]> DESCRIBE data;
|
# MariaDB [curiousgreg]> DESCRIBE data;
|
||||||
# +---------------------+--------------+------+-----+------------------------------------------------+-------+
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
# | Field | Type | Null | Key | Default | Extra |
|
# | Field | Type | Null | Key | Default | Extra |
|
||||||
# +---------------------+--------------+------+-----+------------------------------------------------+-------+
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
# | username | varchar(64) | NO | PRI | NULL | |
|
# | username | varchar(64) | NO | PRI | NULL | |
|
||||||
# | instance | varchar(128) | NO | PRI | NULL | |
|
# | instance | varchar(128) | NO | PRI | NULL | |
|
||||||
# | password | tinytext | NO | | NULL | |
|
# | password | tinytext | NO | | NULL | |
|
||||||
# | avi | text | NO | | NULL | |
|
# | avi | text | NO | | NULL | |
|
||||||
# | secret | tinytext | NO | | NULL | |
|
# | secret | tinytext | NO | | NULL | |
|
||||||
# | client_id | varchar(128) | NO | | NULL | |
|
# | client_id | varchar(128) | NO | | NULL | |
|
||||||
# | client_secret | tinytext | NO | | NULL | |
|
# | client_secret | tinytext | NO | | NULL | |
|
||||||
# | cc | tinytext | YES | | NULL | |
|
# | cc | tinytext | YES | | NULL | |
|
||||||
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
# | ccavi | varchar(128) | YES | | https://lynnesbian.space/res/ceres/cc-smol.png | |
|
||||||
# | latest_post | tinytext | YES | | NULL | |
|
# | latest_post | tinytext | YES | | NULL | |
|
||||||
# | time_between_checks | int(11) | YES | | NULL | |
|
# | latest_timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
||||||
# | settings | longtext | YES | | NULL | |
|
# | time_between_checks | int(11) | YES | | NULL | |
|
||||||
# +---------------------+--------------+------+-----+------------------------------------------------+-------+
|
# | settings | longtext | YES | | NULL | |
|
||||||
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, time_between_checks INT, settings LONGTEXT, PRIMARY KEY(username, instance))")
|
# +---------------------+--------------+------+-----+------------------------------------------------+-----------------------------+
|
||||||
|
c.execute("CREATE TABLE IF NOT EXISTS `data` (username VARCHAR(64) NOT NULL, instance VARCHAR(128) NOT NULL, password TINYTEXT NOT NULL, avi TEXT NOT NULL, secret TINYTEXT NOT NULL, client_id VARCHAR(128) NOT NULL, client_secret TINYTEXT NOT NULL, cc TINYTEXT, ccavi VARCHAR(128) DEFAULT 'https://lynnesbian.space/res/ceres/cc-smol.png', latest_post TINYTEXT, latest_timestamp TIMESTAMP, time_between_checks INT, settings LONGTEXT, PRIMARY KEY(username, instance))")
|
||||||
|
|
||||||
app = Flask(cfg['name'])
|
app = Flask(cfg['name'])
|
||||||
app.secret_key = cfg['flask_key']
|
app.secret_key = cfg['flask_key']
|
||||||
|
@ -193,8 +194,7 @@ def ccc_a(): #step one of curiouscat connection: retreive details
|
||||||
session['cctemp'] = {
|
session['cctemp'] = {
|
||||||
"cc":j['userData']['username'],
|
"cc":j['userData']['username'],
|
||||||
"ccavi":j['userData']['avatar'],
|
"ccavi":j['userData']['avatar'],
|
||||||
"ccid":j['userData']['id'],
|
"ccid":j['userData']['id']
|
||||||
"latest_post":j['posts'][0]['timestamp']
|
|
||||||
}
|
}
|
||||||
return redirect('/cc_connect/confirm')
|
return redirect('/cc_connect/confirm')
|
||||||
|
|
||||||
|
@ -222,16 +222,3 @@ def ccc_b():
|
||||||
@app.route('/cc_connect/code')
|
@app.route('/cc_connect/code')
|
||||||
def cc_connect_code():
|
def cc_connect_code():
|
||||||
return render_template('cc_connect_code.html')
|
return render_template('cc_connect_code.html')
|
||||||
|
|
||||||
@app.route('/internal/ccc_c', methods=['POST'])
|
|
||||||
def ccc_c():
|
|
||||||
if request.form['challenge'] != session['cctemp']['challenge']:
|
|
||||||
return redirect('/cc_connect/code?invalid')
|
|
||||||
for item in ['cc', 'ccavi']:
|
|
||||||
session[item] = session['cctemp'][item]
|
|
||||||
c.execute("UPDATE data SET cc = %s, ccavi = %s, latest_post = %s, time_between_checks = %s WHERE username = %s AND instance = %s", (session['cc'], session['ccavi'], session['cctemp']['latest_post'], 1, session['username'], session['instance']))
|
|
||||||
redirect('/cc_connect/complete')
|
|
||||||
|
|
||||||
@app.route('/cc_connect/complete')
|
|
||||||
def cc_connect_complete():
|
|
||||||
return render_template('cc_connect_complete.html', bg="background-image:url('{}')".format(session['ccavi']))
|
|
||||||
|
|
Loading…
Reference in a new issue