Skip to content

Commit 89010f9

Browse files
committed
Fixed credentialsmanager, cancelling command, logging in without credentials manager and handling credentials saved state
1 parent 48fac5e commit 89010f9

File tree

7 files changed

+35
-34
lines changed

7 files changed

+35
-34
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazy-admin",
3-
"version": "0.4.7",
3+
"version": "0.4.8",
44
"description": "GUI for PowerShell scripts to simplify day to day IT tasks.",
55
"productName": "Lazy Admin",
66
"cordovaId": "eu.houby-studio.lazy-admin",
@@ -29,7 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@quasar/app": "^1.9.6",
32-
"@quasar/quasar-app-extension-qmarkdown": "^1.0.30",
32+
"@quasar/quasar-app-extension-qmarkdown": "^1.0.31",
3333
"@vue/eslint-config-standard": "^4.0.0",
3434
"awesome-node-loader": "^1.1.1",
3535
"babel-eslint": "^10.0.1",

src/layouts/FullLayout.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<q-layout view="hhh lpr lff">
33
<q-header
44
:reveal-offset="Infinity"
5+
@focusin="$event"
6+
class="window-color window-color-text"
57
elevated
68
reveal
7-
class="window-color window-color-text"
89
>
910
<window-titlebar
1011
@minimize="minimize"

src/layouts/LoginLayout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<q-layout view="hHh lpR fFf">
33

44
<q-header
5-
elevated
65
class="window-color text-white"
6+
elevated
77
>
88
<window-titlebar
99
@minimize="minimize"

src/pages/LoginPage.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,12 @@ export default {
216216
console.log(data.output) // Should write 'New Powershell session created succesfully.' from PS Function output
217217
// Route to main screen
218218
if (!this.credentialsSaved) {
219-
this.$pwsh.shell.addCommand(`if (Get-Command New-StoredCredential -ErrorAction SilentlyContinue) {New-StoredCredential -Target 'Lazy Admin' -UserName '${this.username}' -Password '${this.password}' -Comment 'Administrator credentials for Lazy Admin Utility.' -Type Generic -Persist LocalMachine | Out-Null}`)
219+
this.$pwsh.shell.addCommand(`if (Get-Command New-StoredCredential -ErrorAction SilentlyContinue) {New-StoredCredential -Target 'Lazy Admin' -UserName '${this.username}' -Password '${this.password}' -Comment 'Administrator credentials for Lazy Admin Utility.' -Type Generic -Persist LocalMachine | Out-Null} else {"failed"}`)
220220
this.$pwsh.shell.invoke().then(o => {
221-
console.log('Succesfully saved credentials to Credential Manager.')
222-
this.credentialsSaved = true
221+
if (!o.startsWith('failed')) {
222+
console.log('Succesfully saved credentials to Credential Manager.')
223+
this.credentialsSaved = true
224+
}
223225
}).catch(e => {
224226
console.error(`Failed to save credentials to Credential Manager. Error message: ${e}`)
225227
})
@@ -281,6 +283,7 @@ export default {
281283
}
282284
// If module did not load, warn user that he might be missing module
283285
if (jsonOutput.error) {
286+
this.credentialsSaved = false
284287
console.warn('Could not load "CredentialManager" module. It may be missing in the computer.')
285288
this.$q.notify({
286289
timeout: 5000,
@@ -311,6 +314,7 @@ export default {
311314
this.$refs.login.$el.focus()
312315
} else {
313316
console.log(`Could not find any saved credentials.`)
317+
this.credentialsSaved = false
314318
}
315319
}
316320
this.pwshFallbackNotify()

src/pages/ScriptsPage.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,7 @@ export default {
206206
}
207207
// Create new PowerShell instance
208208
this.$pwsh.createShell((done) => {
209-
if (!(this.credentialsSaved) && !(this.loginSkipped)) {
210-
// User logged in, but did not save credentials, likely missing credentials module, redirect to login page.
211-
this.toggleLoading()
212-
this.$router.push({ path: '/' })
213-
} else if (this.loginSkipped) {
209+
if (this.loginSkipped) {
214210
// User skipped logging in, do not attempt to log in and just load plain PowerShell with empty Credential Object.
215211
this.$pwsh.shell.addCommand(`$Global:CredentialObject = [System.Management.Automation.PSCredential]::Empty`)
216212
this.$pwsh.shell.invoke().then(output => {
@@ -400,7 +396,6 @@ export default {
400396
}
401397
}, 1000)
402398
}
403-
console.log('executing')
404399
this.$pwsh.shell.invoke().then(output => {
405400
// Code block to handle PowerShell return data
406401
// Stop listening to output, hide progress dialog and reset dialog

src/statics/pwsh/scripts/New-PSSessionWithCredentials.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function New-PSSessionWithCredentials {
3535
[string]$Password
3636
)
3737
38+
Import-Module -Name "CredentialManager" -UseWindowsPowerShell -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
3839
Import-Module -Name "CredentialManager" -ErrorAction SilentlyContinue
3940
4041
# If credential object should be used, attempt to retrieve it.

yarn.lock

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,20 +1127,20 @@
11271127
resolved "https://registry.yarnpkg.com/@quasar/fastclick/-/fastclick-1.1.4.tgz#21ed3e9a4387dcb43022a08af4ef08a5f1abf159"
11281128
integrity sha512-i9wbyV4iT+v4KhtHJynUFhH5LiEPvAEgSnwMqPN4hf/8uRe82nDl5qP5agrp2el1h0HzyBpbvHaW7NB0BPrtvA==
11291129

1130-
"@quasar/quasar-app-extension-qmarkdown@^1.0.30":
1131-
version "1.0.30"
1132-
resolved "https://registry.yarnpkg.com/@quasar/quasar-app-extension-qmarkdown/-/quasar-app-extension-qmarkdown-1.0.30.tgz#b19e33c22f334bbd3bbdc2d64a0072640390a30d"
1133-
integrity sha512-D50UhE2Pdf9QIKviYx8YfnnzAuxYbHCYNNTi6JLf2Rbkn6U40SVz/5s9+3O3EvNSHRpe/zcx8VB0wI9B7S26LQ==
1130+
"@quasar/quasar-app-extension-qmarkdown@^1.0.31":
1131+
version "1.0.31"
1132+
resolved "https://registry.yarnpkg.com/@quasar/quasar-app-extension-qmarkdown/-/quasar-app-extension-qmarkdown-1.0.31.tgz#bcec7ed19564d39d8c1311fa4b86680486836ec1"
1133+
integrity sha512-zYGCrrj1uLoAhUn5l4SpfmQK5zLNYQLgmrkzL2adBsfZuFmxS5Z0pcly+y4L52bjlL4QVsAbQBEcDxs0euPQxg==
11341134
dependencies:
1135-
"@quasar/quasar-ui-qmarkdown" "^1.0.30"
1135+
"@quasar/quasar-ui-qmarkdown" "^1.0.31"
11361136
front-matter "^4.0.2"
11371137
raw-loader "^4.0.1"
11381138
ware-loader "^0.2.4"
11391139

1140-
"@quasar/quasar-ui-qmarkdown@^1.0.30":
1141-
version "1.0.30"
1142-
resolved "https://registry.yarnpkg.com/@quasar/quasar-ui-qmarkdown/-/quasar-ui-qmarkdown-1.0.30.tgz#f5ab7cac94723df73559264b634d2329a18af53b"
1143-
integrity sha512-cGrJRbEwWtBr9RLiwW0lOIdWe7ty983F1XXFbvxG5KkOMl8lFmSpIx70pNySdkWnJ0WVvl/qRgaNXRvx2EpCEQ==
1140+
"@quasar/quasar-ui-qmarkdown@^1.0.31":
1141+
version "1.0.31"
1142+
resolved "https://registry.yarnpkg.com/@quasar/quasar-ui-qmarkdown/-/quasar-ui-qmarkdown-1.0.31.tgz#bc542e2c5ade39633547678862b6589901e87a65"
1143+
integrity sha512-T7cFYimHBuR3Ha0Kblh/TQrO28dZXrzWrIsGoDb4VWNCs4gJlSShbRJcXl6+HxPfSS5h9OdeHQHgdGq1VwE80g==
11441144
dependencies:
11451145
markdown-it "^11.0.0"
11461146
markdown-it-abbr "^1.0.4"
@@ -1309,9 +1309,9 @@
13091309
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
13101310

13111311
"@types/node@*":
1312-
version "14.0.27"
1313-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1"
1314-
integrity sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==
1312+
version "14.6.0"
1313+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
1314+
integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==
13151315

13161316
"@types/node@^12.0.12":
13171317
version "12.12.54"
@@ -1334,9 +1334,9 @@
13341334
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
13351335

13361336
"@types/semver@^7.3.1":
1337-
version "7.3.2"
1338-
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.2.tgz#39a0ee84ac60d77ed994b82c0d43895cbdd0e584"
1339-
integrity sha512-WrIesso5O0K9S/T87Uct2AvmEFqul11PnprQ98BZEyWILz8QYJt6/tlmqSOVKLNUtAgYHU7D9WGsOFVDb35nPA==
1337+
version "7.3.3"
1338+
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.3.tgz#3ad6ed949e7487e7bda6f886b4a2434a2c3d7b1a"
1339+
integrity sha512-jQxClWFzv9IXdLdhSaTf16XI3NYe6zrEbckSpb5xhKfPbWgIyAY0AFyWWWfaiDcBuj3UHmMkCIwSRqpKMTZL2Q==
13401340

13411341
"@types/serve-static@*":
13421342
version "1.13.5"
@@ -3909,9 +3909,9 @@ ejs@^2.3.1, ejs@^2.6.1:
39093909
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==
39103910

39113911
ejs@^3.1.3:
3912-
version "3.1.3"
3913-
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.3.tgz#514d967a8894084d18d3d47bd169a1c0560f093d"
3914-
integrity sha512-wmtrUGyfSC23GC/B1SMv2ogAUgbQEtDmTIhfqielrG5ExIM9TP4UoYdi90jLF1aTcsWCJNEO0UrgKzP0y3nTSg==
3912+
version "3.1.5"
3913+
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.5.tgz#aed723844dc20acb4b170cd9ab1017e476a0d93b"
3914+
integrity sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==
39153915
dependencies:
39163916
jake "^10.6.1"
39173917

@@ -8451,9 +8451,9 @@ [email protected]:
84518451
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
84528452

84538453
querystringify@^2.1.1:
8454-
version "2.1.1"
8455-
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.1.1.tgz#60e5a5fd64a7f8bfa4d2ab2ed6fdf4c85bad154e"
8456-
integrity sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA==
8454+
version "2.2.0"
8455+
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
8456+
integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==
84578457

84588458
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
84598459
version "2.1.0"

0 commit comments

Comments
 (0)