fsd
This commit is contained in:
parent
123cc81604
commit
d456aaa0c7
18 changed files with 119 additions and 119 deletions
|
@ -11,7 +11,7 @@ from sqlalchemy.orm import joinedload
|
|||
@auth_required
|
||||
def authorize_prompt(v):
|
||||
client_id = request.values.get("client_id")
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).one_or_none()
|
||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||
if not v or v.oldsite: template = ''
|
||||
else: template = 'CHRISTMAS/'
|
||||
|
@ -25,7 +25,7 @@ def authorize_prompt(v):
|
|||
def authorize(v):
|
||||
|
||||
client_id = request.values.get("client_id")
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).first()
|
||||
application = g.db.query(OauthApp).filter_by(client_id=client_id).one_or_none()
|
||||
if not application: return {"oauth_error": "Invalid `client_id`"}, 401
|
||||
access_token = secrets.token_urlsafe(128)[:128]
|
||||
new_auth = ClientAuth(oauth_client = application.id, user_id = v.id, access_token=access_token)
|
||||
|
@ -66,7 +66,7 @@ def request_api_keys(v):
|
|||
def delete_oauth_app(v, aid):
|
||||
|
||||
aid = int(aid)
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
|
||||
if app.author_id != v.id: abort(403)
|
||||
|
||||
|
@ -87,7 +87,7 @@ def delete_oauth_app(v, aid):
|
|||
def edit_oauth_app(v, aid):
|
||||
|
||||
aid = int(aid)
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
|
||||
if app.author_id != v.id: abort(403)
|
||||
|
||||
|
@ -108,7 +108,7 @@ def edit_oauth_app(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_approve(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
user = app.author
|
||||
|
||||
app.client_id = secrets.token_urlsafe(64)[:64]
|
||||
|
@ -143,7 +143,7 @@ def admin_app_approve(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_revoke(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
if app.id:
|
||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
|
||||
|
@ -169,7 +169,7 @@ def admin_app_revoke(v, aid):
|
|||
@validate_formkey
|
||||
def admin_app_reject(v, aid):
|
||||
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
app = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
|
||||
for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth)
|
||||
|
||||
|
@ -198,7 +198,7 @@ def admin_app_id(v, aid):
|
|||
oauth = g.db.query(OauthApp).options(
|
||||
joinedload(
|
||||
OauthApp.author)).filter_by(
|
||||
id=aid).first()
|
||||
id=aid).one_or_none()
|
||||
|
||||
pids=oauth.idlist(page=int(request.values.get("page",1)),
|
||||
)
|
||||
|
@ -226,7 +226,7 @@ def admin_app_id_comments(v, aid):
|
|||
oauth = g.db.query(OauthApp).options(
|
||||
joinedload(
|
||||
OauthApp.author)).filter_by(
|
||||
id=aid).first()
|
||||
id=aid).one_or_none()
|
||||
|
||||
cids=oauth.comments_idlist(page=int(request.values.get("page",1)),
|
||||
)
|
||||
|
@ -267,7 +267,7 @@ def reroll_oauth_tokens(aid, v):
|
|||
|
||||
aid = aid
|
||||
|
||||
a = g.db.query(OauthApp).filter_by(id=aid).first()
|
||||
a = g.db.query(OauthApp).filter_by(id=aid).one_or_none()
|
||||
|
||||
if a.author_id != v.id: abort(403)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue