Compare commits
2 commits
5202b48bd8
...
c3f3cccf1f
Author | SHA1 | Date | |
---|---|---|---|
c3f3cccf1f | |||
2cd1e24633 |
7 changed files with 7 additions and 59 deletions
|
@ -1,40 +0,0 @@
|
|||
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)
|
||||
}
|
|
@ -7,11 +7,8 @@
|
|||
<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'>
|
||||
<form action='/internal/create_account' 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 />
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
<body>
|
||||
<h1>Welcome</h1>
|
||||
<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='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.
|
||||
|
|
|
@ -1,3 +1,2 @@
|
|||
<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">
|
|
@ -7,14 +7,11 @@
|
|||
<body>
|
||||
<h1>Curious Greg</h1>
|
||||
<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> -->
|
||||
<form onsubmit='cont(); return false'>
|
||||
<form action='/internal/create_app' method='POST'>
|
||||
<label for='instance'>Instance URL</label><br />
|
||||
<input name='instance' placeholder='mastodon.social' id='instance-input' /><br />
|
||||
<button class='loading'>Sign Up</button>
|
||||
<button>Sign Up</button>
|
||||
</form>
|
||||
<br /><br />
|
||||
<a class='button' href='/login'>Log In</a>
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
<body>
|
||||
<h1>Log in</h1>
|
||||
<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> -->
|
||||
<form action='/internal/do_login' method='POST'>
|
||||
<label for='acct'>Mastodon Account</label><br />
|
||||
|
|
7
web.py
7
web.py
|
@ -4,7 +4,7 @@
|
|||
# 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/.
|
||||
|
||||
import requests, sqlite3, json
|
||||
import requests, sqlite3, json, hashlib
|
||||
from mastodon import Mastodon
|
||||
from flask import Flask, render_template, request, session, redirect, url_for
|
||||
import bcrypt
|
||||
|
@ -96,7 +96,8 @@ def do_login():
|
|||
def create_password():
|
||||
return render_template("create_password.html")
|
||||
|
||||
@app.route('/internal/create_account')
|
||||
@app.route('/internal/create_account', methods=['POST'])
|
||||
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']))
|
||||
pw = bcrypt.hashpw(request.form['pw'], bcrypt.gensalt(15))
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue