Compare commits

..

No commits in common. "c3f3cccf1f8f716730ba4d1cedef57d218f81d15" and "5202b48bd8b0670b66a6c0e08496ae89effe8ab8" have entirely different histories.

7 changed files with 59 additions and 7 deletions

40
static/script.js Normal file
View file

@ -0,0 +1,40 @@
Node.prototype.gel = function (id) {
return this.getElementById(id);
}
Node.prototype.gcn = function (classname) {
return this.getElementsByClassName(classname);
}
function dgel(id) {
return document.getElementById(id);
}
function dgcn(classname) {
return document.getElementsByClassName(classname);
}
/**
* Asynchronous function. Promises the text content of url. Automatically adds/removes from the loading counter.
* @param {string} url URL to request. Note that unless cross-domain is specifically permitted, this URL must come from the same domain as this file.
*/
async function ajax(url) { //must be called from an async function! use 'await', e.g. "var result = await ajax('https://google.com');"
return new Promise(resolve => {
var pageGetter = new XMLHttpRequest;
pageGetter.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
resolve(this.responseText);
} else if (this.readyState == 4) {
resolve('Error: Expecting HTTP 200, got HTTP ' + this.status)
}
}
pageGetter.open('GET', url, true)
pageGetter.send();
});
}
async function cont() {
url = dgel('instance-input').value;
j = await ajax('/internal/auth_a?url=' + url)
console.log(j)
}

View file

@ -7,8 +7,11 @@
<body> <body>
<h1>Create password</h1> <h1>Create password</h1>
<h2>Please enter a password for your new Curious Greg account.</h2> <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> --> <!-- <div id='logo-main'></div> -->
<form action='/internal/create_account' method='POST'> <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> <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 /> <span id='form-avi-label'>@lynnesbian@fedi.lynnesbian.space</span><br /><br />
<label for='pw'>Password</label><br /> <label for='pw'>Password</label><br />

View file

@ -7,6 +7,9 @@
<body> <body>
<h1>Welcome</h1> <h1>Welcome</h1>
<h2>You're all set up and ready to go.</h2> <h2>You're all set up and ready to go.</h2>
<noscript>
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
</noscript>
<!-- <div id='logo-main'></div> --> <!-- <div id='logo-main'></div> -->
<div id='body'> <div id='body'>
You haven't posted to Curious Cat in a while, so we'll wait <strong>14 minutes</strong> until we check for new answers. You haven't posted to Curious Cat in a while, so we'll wait <strong>14 minutes</strong> until we check for new answers.

View file

@ -1,2 +1,3 @@
<link rel='stylesheet' type='text/css' href="{{ url_for('static', filename='style.css') }}" /> <link rel='stylesheet' type='text/css' href="{{ url_for('static', filename='style.css') }}" />
<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet">

View file

@ -7,11 +7,14 @@
<body> <body>
<h1>Curious Greg</h1> <h1>Curious Greg</h1>
<h2>Connect your Curious Cat and Mastodon accounts for automated crossposting.</h2> <h2>Connect your Curious Cat and Mastodon accounts for automated crossposting.</h2>
<noscript>
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
</noscript>
<!-- <div id='logo-main'></div> --> <!-- <div id='logo-main'></div> -->
<form action='/internal/create_app' method='POST'> <form onsubmit='cont(); return false'>
<label for='instance'>Instance URL</label><br /> <label for='instance'>Instance URL</label><br />
<input name='instance' placeholder='mastodon.social' id='instance-input' /><br /> <input name='instance' placeholder='mastodon.social' id='instance-input' /><br />
<button>Sign Up</button> <button class='loading'>Sign Up</button>
</form> </form>
<br /><br /> <br /><br />
<a class='button' href='/login'>Log In</a> <a class='button' href='/login'>Log In</a>

View file

@ -7,6 +7,9 @@
<body> <body>
<h1>Log in</h1> <h1>Log in</h1>
<h2>Log in to your Curious Greg account.</h2> <h2>Log in to your Curious Greg account.</h2>
<noscript>
Curious Greg will not function without JavaScript. Please ensure you have JavaScript enabled.
</noscript>
<!-- <div id='logo-main'></div> --> <!-- <div id='logo-main'></div> -->
<form action='/internal/do_login' method='POST'> <form action='/internal/do_login' method='POST'>
<label for='acct'>Mastodon Account</label><br /> <label for='acct'>Mastodon Account</label><br />

7
web.py
View file

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import requests, sqlite3, json, hashlib import requests, sqlite3, json
from mastodon import Mastodon from mastodon import Mastodon
from flask import Flask, render_template, request, session, redirect, url_for from flask import Flask, render_template, request, session, redirect, url_for
import bcrypt import bcrypt
@ -96,8 +96,7 @@ def do_login():
def create_password(): def create_password():
return render_template("create_password.html") return render_template("create_password.html")
@app.route('/internal/create_account', methods=['POST']) @app.route('/internal/create_account')
def create_account(): def create_account():
pw = bcrypt.hashpw(request.form['pw'], bcrypt.gensalt(15)) 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, password, secret, appid, appsecret) VALUES (?, ?, ?, ?, ?)", (session['username'], pw, session['instance_url'], session['secret'], session['client_id'], session['client_secret']))
db.commit() db.commit()