fg
This commit is contained in:
parent
dc0ede19a5
commit
93110a0eb7
7 changed files with 2 additions and 40 deletions
|
@ -84,9 +84,6 @@ def check_ban_evade(v):
|
||||||
g.db.add(ma)
|
g.db.add(ma)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
try: abort(403)
|
|
||||||
except Exception as e: print(e)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
v.ban_evade +=1
|
v.ban_evade +=1
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
|
@ -227,7 +227,6 @@ def award_post(pid, v):
|
||||||
return {"error": "You can't give that award multiple times to the same post."}, 409
|
return {"error": "You can't give that award multiple times to the same post."}, 409
|
||||||
|
|
||||||
post_award.submission_id = post.id
|
post_award.submission_id = post.id
|
||||||
#print(f"give award to pid {post_award.submission_id} ({post.id})")
|
|
||||||
g.db.add(post_award)
|
g.db.add(post_award)
|
||||||
|
|
||||||
msg = f"@{v.username} has given your [post]({post.permalink}) the {AWARDS[kind]['title']} Award!"
|
msg = f"@{v.username} has given your [post]({post.permalink}) the {AWARDS[kind]['title']} Award!"
|
||||||
|
|
|
@ -30,19 +30,6 @@ def join_discord(v):
|
||||||
|
|
||||||
return redirect(f"https://discord.com/api/oauth2/authorize?client_id={CLIENT_ID}&redirect_uri=https%3A%2F%2F{app.config['SERVER_NAME']}%2Fdiscord_redirect&response_type=code&scope=identify%20guilds.join&state={state}")
|
return redirect(f"https://discord.com/api/oauth2/authorize?client_id={CLIENT_ID}&redirect_uri=https%3A%2F%2F{app.config['SERVER_NAME']}%2Fdiscord_redirect&response_type=code&scope=identify%20guilds.join&state={state}")
|
||||||
|
|
||||||
@app.get("/sex")
|
|
||||||
@admin_level_required(6)
|
|
||||||
def sex(v):
|
|
||||||
users = g.db.query(User).options(lazyload('*')).filter(User.discord_id != None).all()
|
|
||||||
headers={
|
|
||||||
'Authorization': f"Bot {BOT_TOKEN}",
|
|
||||||
'Content-Type': "application/json"
|
|
||||||
}
|
|
||||||
for u in users:
|
|
||||||
print(u.username)
|
|
||||||
print(u.discord_id)
|
|
||||||
print(requests.patch(f"https://discord.com/api/guilds/846509313497628715/members/{u.discord_id}", headers=headers, data={"nick":u.username}).text)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/discord_redirect")
|
@app.get("/discord_redirect")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
@ -149,13 +136,9 @@ def discord_redirect(v):
|
||||||
else:
|
else:
|
||||||
return x.json()
|
return x.json()
|
||||||
|
|
||||||
#check on if they are already there
|
|
||||||
#print(x.status_code)
|
|
||||||
|
|
||||||
if x.status_code==204:
|
if x.status_code==204:
|
||||||
|
|
||||||
##if user is already a member, remove old roles and update nick
|
|
||||||
|
|
||||||
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}"
|
url=f"https://discord.com/api/guilds/{SERVER_ID}/members/{v.discord_id}"
|
||||||
data={
|
data={
|
||||||
"nick": name
|
"nick": name
|
||||||
|
|
|
@ -33,7 +33,6 @@ def feeds_user(sort='hot', t='all'):
|
||||||
doc.stag("link", href=request.url_root)
|
doc.stag("link", href=request.url_root)
|
||||||
|
|
||||||
for post in posts:
|
for post in posts:
|
||||||
#print("POST IMAGE "+ str( post.is_image ))
|
|
||||||
with tag("entry", ("xml:base", request.url)):
|
with tag("entry", ("xml:base", request.url)):
|
||||||
with tag("title", type="text"):
|
with tag("title", type="text"):
|
||||||
text(post.title)
|
text(post.title)
|
||||||
|
|
|
@ -271,26 +271,21 @@ def sign_up_post(v):
|
||||||
return redirect(f"/signup?{urlencode(args)}")
|
return redirect(f"/signup?{urlencode(args)}")
|
||||||
|
|
||||||
if now - int(form_timestamp) < 5:
|
if now - int(form_timestamp) < 5:
|
||||||
#print(f"signup fail - {username } - too fast")
|
|
||||||
return new_signup("There was a problem. Please try again.")
|
return new_signup("There was a problem. Please try again.")
|
||||||
|
|
||||||
if not hmac.compare_digest(correct_formkey, form_formkey):
|
if not hmac.compare_digest(correct_formkey, form_formkey):
|
||||||
#print(f"signup fail - {username } - mismatched formkeys")
|
|
||||||
return new_signup("There was a problem. Please try again.")
|
return new_signup("There was a problem. Please try again.")
|
||||||
|
|
||||||
# check for matched passwords
|
|
||||||
if not request.values.get(
|
if not request.values.get(
|
||||||
"password") == request.values.get("password_confirm"):
|
"password") == request.values.get("password_confirm"):
|
||||||
return new_signup("Passwords did not match. Please try again.")
|
return new_signup("Passwords did not match. Please try again.")
|
||||||
|
|
||||||
# check username/pass conditions
|
|
||||||
if not re.fullmatch(valid_username_regex, username):
|
if not re.fullmatch(valid_username_regex, username):
|
||||||
return new_signup("Invalid username")
|
return new_signup("Invalid username")
|
||||||
|
|
||||||
if not re.fullmatch(valid_password_regex, request.values.get("password")):
|
if not re.fullmatch(valid_password_regex, request.values.get("password")):
|
||||||
return new_signup("Password must be between 8 and 100 characters.")
|
return new_signup("Password must be between 8 and 100 characters.")
|
||||||
|
|
||||||
# Check for existing accounts
|
|
||||||
email = request.values.get("email")
|
email = request.values.get("email")
|
||||||
email = email.strip()
|
email = email.strip()
|
||||||
if not email: email = None
|
if not email: email = None
|
||||||
|
@ -301,11 +296,9 @@ def sign_up_post(v):
|
||||||
|
|
||||||
if existing_account or (email and g.db.query(
|
if existing_account or (email and g.db.query(
|
||||||
User).filter(User.email.ilike(email)).first()):
|
User).filter(User.email.ilike(email)).first()):
|
||||||
# #print(f"signup fail - {username } - email already exists")
|
|
||||||
return new_signup(
|
return new_signup(
|
||||||
"An account with that username or email already exists.")
|
"An account with that username or email already exists.")
|
||||||
|
|
||||||
# check bot
|
|
||||||
if app.config.get("HCAPTCHA_SITEKEY"):
|
if app.config.get("HCAPTCHA_SITEKEY"):
|
||||||
token = request.values.get("h-captcha-response")
|
token = request.values.get("h-captcha-response")
|
||||||
if not token:
|
if not token:
|
||||||
|
@ -319,21 +312,16 @@ def sign_up_post(v):
|
||||||
x = requests.post(url, data=data)
|
x = requests.post(url, data=data)
|
||||||
|
|
||||||
if not x.json()["success"]:
|
if not x.json()["success"]:
|
||||||
#print(x.json())
|
|
||||||
return new_signup("Unable to verify captcha [2].")
|
return new_signup("Unable to verify captcha [2].")
|
||||||
|
|
||||||
# kill tokens
|
|
||||||
session.pop("signup_token")
|
session.pop("signup_token")
|
||||||
|
|
||||||
# get referral
|
|
||||||
ref_id = int(request.values.get("referred_by", 0))
|
ref_id = int(request.values.get("referred_by", 0))
|
||||||
|
|
||||||
# upgrade user badge
|
|
||||||
if ref_id:
|
if ref_id:
|
||||||
ref_user = g.db.query(User).options(
|
ref_user = g.db.query(User).options(
|
||||||
lazyload('*')).filter_by(id=ref_id).first()
|
lazyload('*')).filter_by(id=ref_id).first()
|
||||||
if ref_user:
|
if ref_user:
|
||||||
# check self-setting badges
|
|
||||||
badge_types = g.db.query(BadgeDef).options(lazyload('*')).filter(BadgeDef.qualification_expr.isnot(None)).all()
|
badge_types = g.db.query(BadgeDef).options(lazyload('*')).filter(BadgeDef.qualification_expr.isnot(None)).all()
|
||||||
for badge in badge_types:
|
for badge in badge_types:
|
||||||
if eval(badge.qualification_expr, {}, {'v': ref_user}):
|
if eval(badge.qualification_expr, {}, {'v': ref_user}):
|
||||||
|
|
|
@ -3,7 +3,7 @@ from urllib.parse import urlparse
|
||||||
import mistletoe
|
import mistletoe
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import gevent
|
import gevent
|
||||||
import traceback
|
import requests
|
||||||
|
|
||||||
from files.helpers.wrappers import *
|
from files.helpers.wrappers import *
|
||||||
from files.helpers.sanitize import *
|
from files.helpers.sanitize import *
|
||||||
|
|
|
@ -381,7 +381,6 @@ def settings_security_post(v):
|
||||||
escape("Passwords do not match."))
|
escape("Passwords do not match."))
|
||||||
|
|
||||||
if not re.match(valid_password_regex, request.values.get("new_password")):
|
if not re.match(valid_password_regex, request.values.get("new_password")):
|
||||||
#print(f"signup fail - {username } - invalid password")
|
|
||||||
return redirect("/settings/security?error=" +
|
return redirect("/settings/security?error=" +
|
||||||
escape("Password must be between 8 and 100 characters."))
|
escape("Password must be between 8 and 100 characters."))
|
||||||
|
|
||||||
|
@ -791,10 +790,7 @@ def settings_song_change(v):
|
||||||
|
|
||||||
|
|
||||||
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails").json()
|
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails").json()
|
||||||
try: duration = req['items'][0]['contentDetails']['duration']
|
duration = req['items'][0]['contentDetails']['duration']
|
||||||
except:
|
|
||||||
print(req)
|
|
||||||
abort(400)
|
|
||||||
if "H" in duration:
|
if "H" in duration:
|
||||||
return render_template("settings_profile.html",
|
return render_template("settings_profile.html",
|
||||||
v=v,
|
v=v,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue