From 4f5199c88f257f17301d3037196cf76382d916c5 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 23 Jul 2020 01:27:46 +0200 Subject: [PATCH] Permetti di disabilitare il login con osu --- royalpack/stars/api_auth_login_osu.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/royalpack/stars/api_auth_login_osu.py b/royalpack/stars/api_auth_login_osu.py index ac3ba1a0..51a2fb74 100644 --- a/royalpack/stars/api_auth_login_osu.py +++ b/royalpack/stars/api_auth_login_osu.py @@ -91,9 +91,12 @@ class ApiAuthLoginOsuStar(rca.ApiStar): raise rcae.ForbiddenError("Unknown osu! account") user = osu.user - token: rbt.Token = TokenT.generate(alchemy=self.alchemy, user=user, expiration_delta=datetime.timedelta(days=7)) + if self.config["osu"]["login"]["enabled"]: + token: rbt.Token = TokenT.generate(alchemy=self.alchemy, user=user, expiration_delta=datetime.timedelta(days=7)) + data.session.add(token) + await data.session_commit() - data.session.add(token) - await data.session_commit() - - return token.json() + return token.json() + else: + raise rcae.ForbiddenError("Account linked successfully; cannot use this account to generate a Royalnet" + " login token, as osu! login is currently disabled on this Royalnet instance.") \ No newline at end of file