Skip to content

Commit

Permalink
Merge pull request #6 from Exifly:hotfix/set-authentication-true-default
Browse files Browse the repository at this point in the history
fix: Configured the Auth settings to true when logged correctly
  • Loading branch information
gdjohn4s authored Apr 12, 2024
2 parents 840affe + b0a6003 commit e2661c3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 21 deletions.
5 changes: 4 additions & 1 deletion codeishot_extension/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ out/
./out
out

## Bundlers
*vsix

## Testing
.vscode-test
.vscode-test
4 changes: 2 additions & 2 deletions codeishot_extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions codeishot_extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "codeishot",
"description": "Share you code in one click",
"icon": "./assets/logo.png",
"version": "0.4.0",
"version": "0.5.0",
"repository": {
"type": "git",
"url": "https://github.com/Exifly/codeishot_vscode_ext"
Expand All @@ -15,7 +15,9 @@
"categories": [
"Other"
],
"activationEvents": ["onUri"],
"activationEvents": [
"onUri"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
Expand All @@ -27,7 +29,6 @@
"command": "extension.postSnippet",
"title": "Share on Codeishot ✨"
}

],
"menus": {
"editor/context": [
Expand All @@ -54,18 +55,18 @@
"type": "object",
"title": "Codeishot",
"properties": {
"jwt": {
"type": "string",
"default": "",
"description": "Token to login into codeishot."
},
"Authentication": {
"type": "boolean",
"default": false,
"description": "Choose whether to authenticate the snippets or not."
}
"jwt": {
"type": "string",
"default": "",
"description": "Token to login into codeishot."
},
"Authentication": {
"type": "boolean",
"default": false,
"description": "Choose whether to authenticate the snippets or not."
}
}
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down
2 changes: 1 addition & 1 deletion codeishot_extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* MIT License
* Copyright (c) [2024] [Codeishot]
* Copyright (c) 2024 Codeishot
* Giovanni D'Andrea => @gdjohn4s
* Flavio Adamo => @FlavioAdamo
* Gianluca Andretta => @gnlca
Expand Down
12 changes: 10 additions & 2 deletions codeishot_extension/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
* Defines various handlers for this vscode extension.
*/

import { window, Uri, type Disposable } from "vscode";
import { updateUserConfiguration } from "./utils";
import { updateUserConfiguration, updateConfiguration } from "./utils";
import { window, Uri, type Disposable, ConfigurationTarget } from "vscode";
import { isAuthApproved } from "./preferences";

export const loginUriHandler: Disposable = window.registerUriHandler({
handleUri(uri: Uri) {
Expand All @@ -12,6 +13,13 @@ export const loginUriHandler: Disposable = window.registerUriHandler({
if (jwtParam) {
window.showInformationMessage("Logged Successfully! ✨");
updateUserConfiguration(jwtParam);

if (!isAuthApproved())
updateConfiguration(
"Authentication",
true,
ConfigurationTarget.Global
);
}
}
},
Expand Down
15 changes: 14 additions & 1 deletion codeishot_extension/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ function useConfig(): WorkspaceConfiguration {
return config;
}

function updateConfiguration(
section: string,
value: string | number | boolean,
target: ConfigurationTarget
) {
workspace.getConfiguration().update(section, value, target);
}

function updateUserConfiguration(token: string) {
workspace.getConfiguration().update("jwt", token, ConfigurationTarget.Global);
}
Expand All @@ -39,4 +47,9 @@ function getTokenFromConfiguration(): string {
return token;
}

export { useConfig, updateUserConfiguration, getTokenFromConfiguration };
export {
useConfig,
updateUserConfiguration,
updateConfiguration,
getTokenFromConfiguration,
};

0 comments on commit e2661c3

Please sign in to comment.