Skip to content

Commit e2661c3

Browse files
author
Giovanni D'Andrea
authored
Merge pull request #6 from Exifly:hotfix/set-authentication-true-default
fix: Configured the Auth settings to true when logged correctly
2 parents 840affe + b0a6003 commit e2661c3

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

codeishot_extension/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ out/
55
./out
66
out
77

8+
## Bundlers
9+
*vsix
10+
811
## Testing
9-
.vscode-test
12+
.vscode-test

codeishot_extension/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codeishot_extension/package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"publisher": "codeishot",
55
"description": "Share you code in one click",
66
"icon": "./assets/logo.png",
7-
"version": "0.4.0",
7+
"version": "0.5.0",
88
"repository": {
99
"type": "git",
1010
"url": "https://github.com/Exifly/codeishot_vscode_ext"
@@ -15,7 +15,9 @@
1515
"categories": [
1616
"Other"
1717
],
18-
"activationEvents": ["onUri"],
18+
"activationEvents": [
19+
"onUri"
20+
],
1921
"main": "./out/extension.js",
2022
"contributes": {
2123
"commands": [
@@ -27,7 +29,6 @@
2729
"command": "extension.postSnippet",
2830
"title": "Share on Codeishot ✨"
2931
}
30-
3132
],
3233
"menus": {
3334
"editor/context": [
@@ -54,18 +55,18 @@
5455
"type": "object",
5556
"title": "Codeishot",
5657
"properties": {
57-
"jwt": {
58-
"type": "string",
59-
"default": "",
60-
"description": "Token to login into codeishot."
61-
},
62-
"Authentication": {
63-
"type": "boolean",
64-
"default": false,
65-
"description": "Choose whether to authenticate the snippets or not."
66-
}
58+
"jwt": {
59+
"type": "string",
60+
"default": "",
61+
"description": "Token to login into codeishot."
62+
},
63+
"Authentication": {
64+
"type": "boolean",
65+
"default": false,
66+
"description": "Choose whether to authenticate the snippets or not."
67+
}
6768
}
68-
}
69+
}
6970
},
7071
"scripts": {
7172
"vscode:prepublish": "npm run compile",

codeishot_extension/src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* MIT License
3-
* Copyright (c) [2024] [Codeishot]
3+
* Copyright (c) 2024 Codeishot
44
* Giovanni D'Andrea => @gdjohn4s
55
* Flavio Adamo => @FlavioAdamo
66
* Gianluca Andretta => @gnlca

codeishot_extension/src/handlers.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
* Defines various handlers for this vscode extension.
33
*/
44

5-
import { window, Uri, type Disposable } from "vscode";
6-
import { updateUserConfiguration } from "./utils";
5+
import { updateUserConfiguration, updateConfiguration } from "./utils";
6+
import { window, Uri, type Disposable, ConfigurationTarget } from "vscode";
7+
import { isAuthApproved } from "./preferences";
78

89
export const loginUriHandler: Disposable = window.registerUriHandler({
910
handleUri(uri: Uri) {
@@ -12,6 +13,13 @@ export const loginUriHandler: Disposable = window.registerUriHandler({
1213
if (jwtParam) {
1314
window.showInformationMessage("Logged Successfully! ✨");
1415
updateUserConfiguration(jwtParam);
16+
17+
if (!isAuthApproved())
18+
updateConfiguration(
19+
"Authentication",
20+
true,
21+
ConfigurationTarget.Global
22+
);
1523
}
1624
}
1725
},

codeishot_extension/src/utils.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ function useConfig(): WorkspaceConfiguration {
1919
return config;
2020
}
2121

22+
function updateConfiguration(
23+
section: string,
24+
value: string | number | boolean,
25+
target: ConfigurationTarget
26+
) {
27+
workspace.getConfiguration().update(section, value, target);
28+
}
29+
2230
function updateUserConfiguration(token: string) {
2331
workspace.getConfiguration().update("jwt", token, ConfigurationTarget.Global);
2432
}
@@ -39,4 +47,9 @@ function getTokenFromConfiguration(): string {
3947
return token;
4048
}
4149

42-
export { useConfig, updateUserConfiguration, getTokenFromConfiguration };
50+
export {
51+
useConfig,
52+
updateUserConfiguration,
53+
updateConfiguration,
54+
getTokenFromConfiguration,
55+
};

0 commit comments

Comments
 (0)