From 37a05f161a28bdbcf6e6c3357959169d1c4cdb89 Mon Sep 17 00:00:00 2001 From: StageGuard <1355416608@qq.com> Date: Mon, 1 Jul 2024 11:44:46 +0800 Subject: [PATCH] catch invalid refresh token exception --- .../obms/osu/api/oauth/OAuthManager.kt | 2 +- src/main/resources/application.yaml | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/application.yaml diff --git a/src/main/kotlin/me/stageguard/obms/osu/api/oauth/OAuthManager.kt b/src/main/kotlin/me/stageguard/obms/osu/api/oauth/OAuthManager.kt index b8c84a5..3c820d4 100644 --- a/src/main/kotlin/me/stageguard/obms/osu/api/oauth/OAuthManager.kt +++ b/src/main/kotlin/me/stageguard/obms/osu/api/oauth/OAuthManager.kt @@ -121,7 +121,7 @@ class OAuthManager { suspend fun updateToken(user: User) : User { if (user.tokenExpireUnixSecond < LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)) { val response = refreshToken(user.refreshToken).mapLeft { - if(it is BadResponseException && it.respondText.contains("401")) { + if(it is BadResponseException && (it.respondText.contains("401") || it.respondText.contains("invalid"))) { InvalidTokenException(user.qq) } else it }.rightOrThrowLeft() diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..a167215 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,26 @@ +server: + port: 5000 +shiro: + ws: + server: + enable: true + url: "/ws/shiro" +qq: 202746796 # 为这个 BOT 启用插件 +database: + address: localhost # 数据库地址 + port: 3306 # 端口 + user: root # 账号 + password: testpwd # 密码 + table: obmsug # 数据库名称(在准备工作第一步创建的数据库) + maximumPoolSize: 10 +clientProxy: '' +osuAuth: + clientId: 8509 # OAuth clientId + secret: 'Pw62qscOyPgnfQIJSv7awxeNQnYSQcowO1p3Pz4G' # OAuth client secret + # 回调地址,必须和 OAuth 设置的相同(不包含 /authCallback) + # 注意这个地址是为了生成绑定账号的 OAuth 链接。 + authCallbackBaseUrl: 'http://localhost:8081' + v1ApiKey: '8c515a93e53b27a719b891b316c40e240cca29d7' # vi api 密钥 +frontend: + host: localhost # 前端主机地址,注意这个地址是实际主机地址 + port: 8081 # 前端端口 \ No newline at end of file