Skip to content

Commit b5a40a6

Browse files
authored
updated with fix for create user (#649)
1 parent 9c1d1a5 commit b5a40a6

File tree

10 files changed

+100
-55
lines changed

10 files changed

+100
-55
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file. For commit guidelines, please refer to [Standard Version](https://github.com/conventional-changelog/standard-version).
44

5+
## v0.7.4-beta
6+
7+
**Notes**:
8+
- Updated German translation. https://github.com/gtsteffaniak/filebrowser/pull/644
9+
10+
**BugFixes**:
11+
- windows control click https://github.com/gtsteffaniak/filebrowser/issues/642
12+
- create user issue https://github.com/gtsteffaniak/filebrowser/issues/647
13+
514
## v0.7.3-beta
615

716
Note: OIDC changes require config update.

backend/database/storage/storage.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
storm "github.com/asdine/storm/v3"
1010
"github.com/gtsteffaniak/filebrowser/backend/auth"
11-
"github.com/gtsteffaniak/filebrowser/backend/common/errors"
1211
"github.com/gtsteffaniak/filebrowser/backend/common/logger"
1312
"github.com/gtsteffaniak/filebrowser/backend/common/settings"
1413
"github.com/gtsteffaniak/filebrowser/backend/common/utils"
@@ -110,8 +109,8 @@ func quickSetup(store *Storage) {
110109
func CreateUser(userInfo users.User, asAdmin bool) error {
111110
newUser := &userInfo
112111
if userInfo.LoginMethod == "password" {
113-
if userInfo.Password != "" {
114-
return errors.ErrInvalidRequestParams
112+
if userInfo.Password == "" {
113+
return fmt.Errorf("password is required to create a password login user")
115114
}
116115
} else {
117116
hashpass, err := users.HashPwd(userInfo.Username)
@@ -122,7 +121,7 @@ func CreateUser(userInfo users.User, asAdmin bool) error {
122121
}
123122
// must have username or password to create
124123
if userInfo.Username == "" {
125-
return errors.ErrInvalidRequestParams
124+
return fmt.Errorf("username is required to create a user")
126125
}
127126
logger.Debug(fmt.Sprintf("Creating user: %v %v", userInfo.Username, userInfo.Scopes))
128127
settings.ApplyUserDefaults(newUser)

frontend/src/components/files/ListingItem.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@mouseup="cancelContext($event)"
3030
>
3131
<div @click="toggleClick" :class="{ 'gallery-div': galleryView }">
32-
<Icon :mimetype="type" :active="isSelected" :thumbnailUrl />
32+
<Icon :mimetype="type" :active="isSelected" :thumbnailUrl="thumbnailUrl" />
3333
</div>
3434

3535
<div class="text" :class="{ activecontent: isMaximized && isSelected }">
@@ -364,7 +364,6 @@ export default {
364364
mutations.removeSelected(this.index);
365365
return;
366366
}
367-
368367
if (event.shiftKey && this.selected.length > 0) {
369368
let fi = 0;
370369
let la = 0;

frontend/src/components/settings/UserForm.vue

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<input
1313
class="input input--block form-form"
1414
:class="{ 'invalid-form': invalidPassword }"
15+
aria-label="Password1"
1516
type="password"
1617
:placeholder="$t('settings.enterPassword')"
1718
v-model="passwordRef"
@@ -21,6 +22,7 @@
2122
<input
2223
class="input input--block form-form"
2324
:class="{ 'flat-right': !isNew, 'invalid-form': invalidPassword }"
25+
aria-label="Password2"
2426
type="password"
2527
:placeholder="$t('settings.enterPasswordAgain')"
2628
v-model="user.password"
@@ -50,34 +52,36 @@
5052
</p>
5153

5254
<div v-if="user.loginMethod == 'password' && passwordAvailable && isNew">
53-
<label for="password">{{ $t("settings.password") }}</label>
54-
<div class="form-group">
55-
<input
56-
class="input input--block form-form"
57-
:class="{ 'invalid-form': invalidPassword }"
58-
type="password"
59-
:placeholder="$t('settings.enterPassword')"
60-
v-model="passwordRef"
61-
/>
62-
</div>
63-
<div class="form-group">
64-
<input
65-
class="input input--block form-form"
66-
:class="{ 'flat-right': !isNew, 'invalid-form': invalidPassword }"
67-
type="password"
68-
:placeholder="$t('settings.enterPasswordAgain')"
69-
v-model="user.password"
70-
id="password"
71-
/>
72-
<button
73-
v-if="!isNew"
74-
type="button"
75-
class="button form-button"
76-
@click="submitUpdatePassword"
77-
>
78-
{{ $t("buttons.update") }}
79-
</button>
80-
</div>
55+
<label for="password">{{ $t("settings.password") }}</label>
56+
<div class="form-group">
57+
<input
58+
class="input input--block form-form"
59+
:class="{ 'invalid-form': invalidPassword }"
60+
aria-label="Password1"
61+
type="password"
62+
:placeholder="$t('settings.enterPassword')"
63+
v-model="passwordRef"
64+
/>
65+
</div>
66+
<div class="form-group">
67+
<input
68+
class="input input--block form-form"
69+
:class="{ 'flat-right': !isNew, 'invalid-form': invalidPassword }"
70+
type="password"
71+
:placeholder="$t('settings.enterPasswordAgain')"
72+
aria-label="Password2"
73+
v-model="user.password"
74+
id="password"
75+
/>
76+
<button
77+
v-if="!isNew"
78+
type="button"
79+
class="button form-button"
80+
@click="submitUpdatePassword"
81+
>
82+
{{ $t("buttons.update") }}
83+
</button>
84+
</div>
8185
</div>
8286

8387
<div
@@ -153,9 +157,9 @@
153157
<div v-if="stateUser.permissions.admin">
154158
<label for="loginMethod">{{ $t("settings.loginMethodDescription") }}</label>
155159
<select v-model="user.loginMethod" class="input input--block" id="loginMethod">
156-
<option value="password">Password</option>
157-
<option value="oidc">OIDC</option>
158-
<option value="proxy">Proxy</option>
160+
<option value="password">Password</option> <!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
161+
<option value="oidc">OIDC</option> <!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
162+
<option value="proxy">Proxy</option> <!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
159163
</select>
160164
</div>
161165
<permissions v-if="stateUser.permissions.admin" :permissions="user.permissions" />
@@ -221,7 +225,8 @@ export default {
221225
},
222226
computed: {
223227
invalidPassword() {
224-
const matching = this.user.password != this.passwordRef && this.user.password.length > 0 ;
228+
const matching =
229+
this.user.password != this.passwordRef && this.user.password.length > 0;
225230
return matching;
226231
},
227232
passwordAvailable: () => passwordAvailable,

frontend/src/views/bars/Default.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@action="multiAction"
99
/>
1010
<search v-if="showSearch" />
11-
<title v-else-if="isSettings" class="topTitle">{{ $t('sidebar.settings') }}</title>
11+
<title v-else-if="isSettings" class="topTitle">{{ $t("sidebar.settings") }}</title>
1212
<title v-else class="topTitle">{{ req.name }}</title>
1313
<action
1414
v-if="isListingView"
@@ -30,7 +30,6 @@
3030
<script>
3131
import router from "@/router";
3232
import { getters, state, mutations } from "@/store";
33-
import { removeLastDir } from "@/utils/url";
3433
import Action from "@/components/Action.vue";
3534
import Search from "@/components/Search.vue";
3635
@@ -124,7 +123,7 @@ export default {
124123
} else {
125124
mutations.closeHovers();
126125
if (listingView === "settings") {
127-
router.push({path: "/files" });
126+
router.push({ path: "/files" });
128127
return;
129128
}
130129
mutations.replaceRequest({});

frontend/src/views/files/ListingView.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ export default {
254254
if (!elem) {
255255
return 1;
256256
}
257-
let columns = Math.floor(
258-
elem.offsetWidth / this.columnWidth
259-
);
257+
let columns = Math.floor(elem.offsetWidth / this.columnWidth);
260258
if (columns === 0) columns = 1;
261259
return columns;
262260
},
@@ -596,7 +594,7 @@ export default {
596594
let newPath = currentPath.substring(0, currentPath.lastIndexOf("/"));
597595
598596
if (modifierKeys) {
599-
if (!ctrlKey) {
597+
if (ctrlKey) {
600598
this.ctrKeyPressed = true;
601599
}
602600
return;

frontend/src/views/settings/User.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
<form @submit="save" class="card active" v-if="loaded">
44
<div class="card-title">
55
<h2 v-if="isNew">{{ $t("settings.newUser") }}</h2>
6-
<h2 v-else-if="actor.id == user.id"> {{ $t('settings.modifyCurrentUser') }} ({{ user.username }})</h2> <!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
7-
<h2 v-else> {{ $t('settings.modifyOtherUser') }} {{ user.username }}</h2>
6+
<h2 v-else-if="actor.id == user.id">
7+
{{ $t("settings.modifyCurrentUser") }} {{ user.username }}
8+
</h2>
9+
<h2 v-else>{{ $t("settings.modifyOtherUser") }} {{ user.username }}</h2>
810
</div>
911

1012
<div class="card-content minimal-card">
@@ -18,16 +20,21 @@
1820

1921
<div v-if="actor.permissions.admin" class="card-action">
2022
<button
21-
v-if="!isNew && actor.permissions.admin"
23+
v-if="!isNew"
2224
@click.prevent="deletePrompt"
2325
type="button"
2426
class="button button--flat button--red"
25-
:aria-label="$t('buttons.delete')"
27+
aria-label="Delete User"
2628
:title="$t('buttons.delete')"
2729
>
2830
{{ $t("buttons.delete") }}
2931
</button>
30-
<input class="button button--flat" type="submit" :value="$t('buttons.save')" />
32+
<input
33+
aria-label="Save User"
34+
class="button button--flat"
35+
type="submit"
36+
:value="$t('buttons.save')"
37+
/>
3138
</div>
3239
</form>
3340
</template>
@@ -107,7 +114,7 @@ export default {
107114
async save(event) {
108115
event.preventDefault();
109116
try {
110-
let fields = ["all"]
117+
let fields = ["all"];
111118
if (!state.user.permissions.admin) {
112119
notify.showError(this.$t("settings.userNotAdmin"));
113120
return;

frontend/src/views/settings/Users.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<div class="card-title">
55
<h2>{{ $t("settings.users") }}</h2>
66
<router-link v-if="isAdmin" to="/settings/users/new">
7-
<button class="button">
7+
<button class="button" aria-label="Add New User">
88
{{ $t("buttons.new") }}
99
</button>
1010
</router-link>
1111
</div>
1212

1313
<div class="card-content full">
14-
<table>
14+
<table aria-label="Users">
1515
<thead>
1616
<tr>
1717
<th>{{ $t("settings.username") }}</th>
18-
<th> {{ $t("settings.loginMethod") }} </th>
18+
<th>{{ $t("settings.loginMethod") }}</th>
1919
<th>{{ $t("settings.admin") }}</th>
2020
<th>Scopes</th> <!-- eslint-disable-line @intlify/vue-i18n/no-raw-text -->
2121
<th></th>
@@ -30,7 +30,7 @@
3030
<i v-else class="material-icons">close</i>
3131
</td>
3232
<td>{{ user.scopes }}</td>
33-
<td class="small">
33+
<td class="small" aria-label="Edit User">
3434
<router-link :to="'/settings/users/' + user.id">
3535
<i class="material-icons">mode_edit</i>
3636
</router-link>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { test, expect } from '../test-setup'
2+
3+
test('create and delete testuser', async ({
4+
page,
5+
checkForErrors,
6+
context
7+
}) => {
8+
await page.goto('/settings')
9+
await expect(page).toHaveTitle("Graham's Filebrowser - Settings")
10+
await page.locator('button[aria-label="Add New User"]').click()
11+
await page.locator('#username').fill('testuser')
12+
await page.locator('input[aria-label="Password1"]').fill('testpassword')
13+
await page.locator('input[aria-label="Password2"]').fill('testpass')
14+
// check that the invalid-field class is added properly
15+
await expect(page.locator('input[aria-label="Password2"]')).toHaveClass(
16+
'input input--block form-form invalid-form'
17+
)
18+
await page.locator('input[aria-label="Password2"]').fill('testpassword')
19+
await page.locator('input[aria-label="Save User"]').click()
20+
21+
// click the edit button for testuser
22+
const userRow = page.locator('tr.item', { hasText: 'testuser' })
23+
const editLink = await userRow
24+
.locator('td[aria-label="Edit User"] a')
25+
.getAttribute('href')
26+
await page.goto(editLink!)
27+
checkForErrors()
28+
})

frontend/tests-playwright/proxy/preview.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ test("Create first new file", async ({ page, checkForErrors, context }) => {
1212
await expect(page.locator('#listingView .file-items')).toHaveCount(1);
1313
checkForErrors();
1414
});
15+

0 commit comments

Comments
 (0)