Compare commits
2 commits
7e8868eb5c
...
594a078515
Author | SHA1 | Date | |
---|---|---|---|
594a078515 | |||
f439703f1a |
3 changed files with 67 additions and 19 deletions
18
templates/cc_connect_code.html
Normal file
18
templates/cc_connect_code.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!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>
|
17
templates/cc_connect_complete.html
Normal file
17
templates/cc_connect_complete.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!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>
|
25
web.py
25
web.py
|
@ -23,9 +23,9 @@ 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 | |
|
||||||
|
@ -36,11 +36,10 @@ dc = db.cursor(dictionary=True)
|
||||||
# | 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 | |
|
||||||
# | latest_timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
|
|
||||||
# | time_between_checks | int(11) | YES | | NULL | |
|
# | time_between_checks | int(11) | YES | | NULL | |
|
||||||
# | settings | longtext | 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, latest_timestamp TIMESTAMP, 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, 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']
|
||||||
|
@ -194,7 +193,8 @@ 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,3 +222,16 @@ 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