TODO: 推翻整个项目重新建立根基
This commit is contained in:
26
client/performAuth.ts
Normal file
26
client/performAuth.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import data from "./Data.ts";
|
||||
import getClient from "./getClient.ts"
|
||||
|
||||
/**
|
||||
* 客户端上线
|
||||
*
|
||||
* 优先级: 账号密码 > 提供刷新令牌 > 储存的刷新令牌
|
||||
*
|
||||
* 不会逐一尝试
|
||||
*/
|
||||
export default async function performAuth(args: {
|
||||
refresh_token?: string
|
||||
account?: string
|
||||
password?: string
|
||||
}) {
|
||||
if (args.account && args.password)
|
||||
await getClient().authOrThrow({
|
||||
account: args.account,
|
||||
password: args.password,
|
||||
})
|
||||
else {
|
||||
await getClient().authOrThrow({ refresh_token: args.refresh_token ? args.refresh_token : data.refresh_token })
|
||||
}
|
||||
data.refresh_token = getClient().getCachedRefreshToken()
|
||||
data.access_token = getClient().getCachedAccessToken()
|
||||
}
|
||||
Reference in New Issue
Block a user