added profile picture to password creation form, changed DB schema to accomodate

This commit is contained in:
Lynne Megido 2018-11-06 21:57:47 +10:00
parent 456c46811d
commit 5202b48bd8
Signed by: lynnesbian
GPG Key ID: FB7B970303ACE499
3 changed files with 24 additions and 8 deletions

View File

@ -57,3 +57,13 @@ button:hover, .button:hover{
background-color:#2b90d9;
color:white;
}
#form-avi {
height: 128px;
width:128px;
margin:0 auto 15px;
background-size:cover;
border-radius:16px;
}
#form-avi-label {
font-size:0.6em;
}

View File

@ -12,10 +12,14 @@
</noscript>
<!-- <div id='logo-main'></div> -->
<form action='/internal/do_login' method='POST'>
<div id='form-avi' style='background-image:url("https://fedi.lynnesbian.space/system/accounts/avatars/000/000/002/original/7ebcb4b973eee926.gif?1541354017")'></div>
<span id='form-avi-label'>@lynnesbian@fedi.lynnesbian.space</span><br /><br />
<label for='pw'>Password</label><br />
<input type='password' name='pw' placeholder='••••••••' required /><br />
<button>Create Account</button>
</form>
<br /><br />
Your password will be hashed using bcrypt, ensuring that nobody can read it.
{% include 'footer.html' %}
</body>
</html>

18
web.py
View File

@ -14,7 +14,7 @@ cfg = json.load(open("meta.json"))
db = sqlite3.connect("database.db") #TODO: switch to mysql so concurrency is possible
c = db.cursor()
c.execute("CREATE TABLE IF NOT EXISTS `data` (username TEXT NOT NULL, instance TEXT NOT NULL, secret TEXT NOT NULL, appid TEXT NOT NULL, appsecret TEXT NOT NULL, cc TEXT, latest_post TEXT, latest_timestamp TEXT, time_between_checks INT)")
c.execute("CREATE TABLE IF NOT EXISTS `data` (username TEXT NOT NULL, instance TEXT NOT NULL, password TEXT NOT NULL, avi TEXT NOT NULL, secret TEXT NOT NULL, appid TEXT NOT NULL, appsecret TEXT NOT NULL, cc TEXT, latest_post TEXT, latest_timestamp TEXT, time_between_checks INT)")
app = Flask(cfg['name'])
app.secret_key = cfg['flask_key']
@ -51,7 +51,7 @@ def log_in():
#internal stuff
@app.route('/internal/auth_a')
def internal_auth_a():
def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow
session['instance_url'] = request.args.get('url', default='mastodon.social', type=str)
if not session['instance_url'].startswith("https://"):
@ -73,7 +73,6 @@ def internal_auth_a():
}
url = "{}/oauth/authorize?{}".format(session['instance_url'], urllib.parse.urlencode(params))
return url
@app.route('/internal/auth_b')
@ -86,10 +85,8 @@ def internal_auth_b():
if c.execute("SELECT COUNT(*) FROM data WHERE username LIKE ? AND instance LIKE ?", (session['username'], session['instance_url'])).fetchone()[0] > 0:
#user already has an account with CG
return redirect(url_for('log_in'))
c.execute("INSERT INTO data (username, instance, secret, appid, appsecret) VALUES (?, ?, ?, ?, ?)", (session['username'], session['instance_url'], session['secret'], session['client_id'], session['client_secret']))
db.commit()
return redirect(url_for('home'))
else:
return redirect(url_for('home'))
@app.route('/internal/do_login')
def do_login():
@ -97,4 +94,9 @@ def do_login():
@app.route('/create_password')
def create_password():
return render_template("create_password.html")
return render_template("create_password.html")
@app.route('/internal/create_account')
def create_account():
c.execute("INSERT INTO data (username, instance, secret, appid, appsecret) VALUES (?, ?, ?, ?, ?)", (session['username'], session['instance_url'], session['secret'], session['client_id'], session['client_secret']))
db.commit()