added password creation page

This commit is contained in:
Lynne Megido 2018-11-06 21:22:10 +10:00
parent 3910fcf0a6
commit d17093ab3e
Signed by: lynnesbian
GPG key ID: FB7B970303ACE499
2 changed files with 46 additions and 8 deletions

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Curious Greg - Create Password</title>
{% include 'imports.html' %}
</head>
<body>
<h1>Create password</h1>
<h2>Please enter a password for your new Curious Greg account.</h2>
<noscript>
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
</noscript>
<!-- <div id='logo-main'></div> -->
<form action='/internal/do_login' method='POST'>
<label for='pw'>Password</label><br />
<input type='password' name='pw' placeholder='••••••••' required /><br />
<label for='pw2'>Retype password</label><br />
<input type='password' placeholder='••••••••' name='pw2' required /><br />
<button>Create Account</button>
</form>
{% include 'footer.html' %}
</body>
</html>

31
web.py
View file

@ -34,6 +34,22 @@ def home():
else: else:
return redirect(url_for('main')) return redirect(url_for('main'))
@app.route('/debug') #TODO: remove this before making the site live ;p
def print_debug_info():
return json.dumps(session._get_current_object())
@app.route('/login')
def log_in():
if 'acct' in session:
#user is probably already logged in. if they aren't, home() will handle things and redirect them back here
return redirect(url_for('home'))
return render_template("login.html")
# return(json.dumps(client_info))
#internal stuff
@app.route('/internal/auth_a') @app.route('/internal/auth_a')
def internal_auth_a(): def internal_auth_a():
@ -70,16 +86,15 @@ 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: 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 #user already has an account with CG
return redirect(url_for('log_in')) 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'])) 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() db.commit()
return redirect(url_for('home')) return redirect(url_for('home'))
@app.route('/debug') @app.route('/internal/do_login')
def print_debug_info(): def do_login():
return json.dumps(session._get_current_object()) pass
@app.route('/login') @app.route('/create_password')
def log_in(): def create_password():
return render_template("login.html") return render_template("create_password.html")
# return(json.dumps(client_info))