Compare commits
No commits in common. "5202b48bd8b0670b66a6c0e08496ae89effe8ab8" and "3910fcf0a69ebfcdba213c453f37d5ea64747213" have entirely different histories.
5202b48bd8
...
3910fcf0a6
3 changed files with 14 additions and 66 deletions
|
@ -57,13 +57,3 @@ 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;
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<!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'>
|
||||
<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>
|
45
web.py
45
web.py
|
@ -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, 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)")
|
||||
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)")
|
||||
|
||||
app = Flask(cfg['name'])
|
||||
app.secret_key = cfg['flask_key']
|
||||
|
@ -34,24 +34,8 @@ def home():
|
|||
else:
|
||||
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')
|
||||
def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow
|
||||
def internal_auth_a():
|
||||
|
||||
session['instance_url'] = request.args.get('url', default='mastodon.social', type=str)
|
||||
if not session['instance_url'].startswith("https://"):
|
||||
|
@ -73,6 +57,7 @@ def internal_auth_a(): #TODO: prevent these endpoints from being spammed somehow
|
|||
}
|
||||
|
||||
url = "{}/oauth/authorize?{}".format(session['instance_url'], urllib.parse.urlencode(params))
|
||||
|
||||
return url
|
||||
|
||||
@app.route('/internal/auth_b')
|
||||
|
@ -85,18 +70,16 @@ 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'))
|
||||
else:
|
||||
return redirect(url_for('home'))
|
||||
|
||||
@app.route('/internal/do_login')
|
||||
def do_login():
|
||||
pass
|
||||
|
||||
@app.route('/create_password')
|
||||
def create_password():
|
||||
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()
|
||||
return redirect(url_for('home'))
|
||||
|
||||
@app.route('/debug')
|
||||
def print_debug_info():
|
||||
return json.dumps(session._get_current_object())
|
||||
|
||||
@app.route('/login')
|
||||
def log_in():
|
||||
return render_template("login.html")
|
||||
|
||||
# return(json.dumps(client_info))
|
||||
|
|
Loading…
Reference in a new issue