mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 02:24:18 +00:00
improve authorization
This commit is contained in:
parent
64303dac7e
commit
aa1f2f0913
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ragestudio/relic-core",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.5",
|
||||
"license": "MIT",
|
||||
"author": "RageStudio",
|
||||
"description": "RageStudio Relic, yet another package manager.",
|
||||
|
@ -33,4 +33,12 @@ export default class ManifestAuthService {
|
||||
|
||||
return await db.data[pkg_id]
|
||||
}
|
||||
|
||||
static delete = async (pkg_id) => {
|
||||
const db = await this.withDB()
|
||||
|
||||
return await db.update((data) => {
|
||||
delete data[pkg_id]
|
||||
})
|
||||
}
|
||||
}
|
28
packages/core/src/handlers/deauthorize.js
Normal file
28
packages/core/src/handlers/deauthorize.js
Normal file
@ -0,0 +1,28 @@
|
||||
import ManifestAuthDB from "../classes/ManifestAuthDB"
|
||||
import DB from "../db"
|
||||
|
||||
import Logger from "../logger"
|
||||
|
||||
const Log = Logger.child({ service: "AUTH" })
|
||||
|
||||
export default async (pkg_id) => {
|
||||
if (!pkg_id) {
|
||||
Log.error("pkg_id is required")
|
||||
return false
|
||||
}
|
||||
|
||||
const pkg = await DB.getPackages(pkg_id)
|
||||
|
||||
if (!pkg) {
|
||||
Log.error("Package not found")
|
||||
return false
|
||||
}
|
||||
|
||||
Log.info(`Deleting auth for [${pkg_id}]`)
|
||||
|
||||
await ManifestAuthDB.delete(pkg_id)
|
||||
|
||||
global._relic_eventBus.emit("pkg:deauthorized", pkg)
|
||||
|
||||
return true
|
||||
}
|
@ -43,6 +43,8 @@ export default async function execute(pkg_id, { useRemote = false, force = false
|
||||
return false
|
||||
}
|
||||
|
||||
BaseLog.info(`Executing manifest > [${manifestPath}]`)
|
||||
|
||||
global._relic_eventBus.emit(`pkg:update:state`, {
|
||||
id: pkg.id,
|
||||
last_status: "loading",
|
||||
|
@ -17,6 +17,7 @@ import PackageApply from "./handlers/apply"
|
||||
import PackageList from "./handlers/list"
|
||||
import PackageRead from "./handlers/read"
|
||||
import PackageAuthorize from "./handlers/authorize"
|
||||
import PackageDeauthorize from "./handlers/deauthorize"
|
||||
import PackageCheckUpdate from "./handlers/checkUpdate"
|
||||
import PackageLastOperationRetry from "./handlers/lastOperationRetry"
|
||||
|
||||
@ -56,6 +57,7 @@ export default class RelicCore {
|
||||
list: PackageList,
|
||||
read: PackageRead,
|
||||
authorize: PackageAuthorize,
|
||||
deauthorize: PackageDeauthorize,
|
||||
checkUpdate: PackageCheckUpdate,
|
||||
lastOperationRetry: PackageLastOperationRetry,
|
||||
}
|
||||
|
@ -16,13 +16,11 @@ export default class Auth {
|
||||
}
|
||||
|
||||
const result = await axios({
|
||||
method: "POST",
|
||||
method: "GET",
|
||||
url: this.manifest.authService.getter,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
auth_data: storagedData,
|
||||
"Authorization": `Bearer ${storagedData}`
|
||||
}
|
||||
}).catch((err) => {
|
||||
global._relic_eventBus.emit("auth:getter:error", err)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ragestudio/relic-gui",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.5",
|
||||
"description": "RageStudio Relic, yet another package manager.",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "RageStudio",
|
||||
@ -24,7 +24,7 @@
|
||||
"@getstation/electron-google-oauth2": "^14.0.0",
|
||||
"@imjs/electron-differential-updater": "^5.1.7",
|
||||
"@loadable/component": "^5.16.3",
|
||||
"@ragestudio/relic-core": "^0.17.0",
|
||||
"@ragestudio/relic-core": "^0.17.5",
|
||||
"antd": "^5.13.2",
|
||||
"classnames": "^2.3.2",
|
||||
"electron-differential-updater": "^4.3.2",
|
||||
|
@ -65,6 +65,9 @@ export default class CoreAdapter {
|
||||
"pkg:cancel_current_operation": async (event, pkg_id) => {
|
||||
return await this.core.package.cancelCurrentOperation(pkg_id)
|
||||
},
|
||||
"pkg:delete_auth": async (event, pkg_id) => {
|
||||
return await this.core.package.deauthorize(pkg_id)
|
||||
},
|
||||
"core:open-path": async (event, pkg_id) => {
|
||||
return await this.core.openPath(pkg_id)
|
||||
},
|
||||
@ -109,6 +112,13 @@ export default class CoreAdapter {
|
||||
description: `${pkg.name} has been authorized! You can start the package now.`,
|
||||
})
|
||||
},
|
||||
"pkg:deauthorized": (pkg) => {
|
||||
sendToRender(`new:notification`, {
|
||||
type: "success",
|
||||
message: "Package deauthorized",
|
||||
description: `${pkg.name} has been deauthorized`,
|
||||
})
|
||||
},
|
||||
"pkg:error": (data) => {
|
||||
sendToRender(`new:notification`, {
|
||||
type: "error",
|
||||
|
@ -237,16 +237,14 @@ const PackageOptions = (props) => {
|
||||
</div>
|
||||
|
||||
<div className="package_options-actions">
|
||||
{
|
||||
manifest.auth && <antd.Button
|
||||
onClick={handleDeleteAuth}
|
||||
type="default"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
>
|
||||
Delete auth
|
||||
</antd.Button>
|
||||
}
|
||||
<antd.Button
|
||||
onClick={handleDeleteAuth}
|
||||
type="default"
|
||||
size="small"
|
||||
disabled={loading}
|
||||
>
|
||||
Delete auth
|
||||
</antd.Button>
|
||||
|
||||
<antd.Button
|
||||
onClick={handleReinstall}
|
||||
|
Loading…
x
Reference in New Issue
Block a user