Skip to content

Commit 5ffbe91

Browse files
Small pytest fix
1 parent 8870563 commit 5ffbe91

File tree

5 files changed

+6
-36
lines changed

5 files changed

+6
-36
lines changed

pydatalab/src/pydatalab/routes/v0_1/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def list_access_tokens():
150150
"active": 1,
151151
"created_at": 1,
152152
"invalidated_at": 1,
153-
"token": {"$substr": ["$token", 0, 16]},
153+
"token": "$token",
154154
"item_name": {
155155
"$cond": {
156156
"if": {"$gt": [{"$size": "$item_info"}, 0]},

pydatalab/src/pydatalab/routes/v0_1/items.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ def update_item_permissions(refcode: str):
754754

755755

756756
@ITEMS.route("/items/<refcode>/issue-access-token", methods=["POST"])
757-
@active_users_or_get_only
758757
def issue_physical_token(refcode: str):
759758
"""Issue a token that will give semi-permanent access to an
760759
item with this refcode. This should be used when generating
@@ -872,14 +871,9 @@ def get_item_data(item_id: str | None = None, refcode: str | None = None):
872871
redirect_url += f"?at={access_token}"
873872
return redirect(redirect_url, code=307)
874873

875-
valid_access_token: bool = False
874+
valid_access_token = False
876875
if refcode and access_token:
877876
valid_access_token = check_access_token(refcode, access_token)
878-
if not valid_access_token:
879-
return (
880-
jsonify({"status": "error", "message": "Invalid access token"}),
881-
401,
882-
)
883877

884878
if item_id:
885879
match = {"item_id": item_id}
@@ -932,24 +926,6 @@ def get_item_data(item_id: str | None = None, refcode: str | None = None):
932926
404,
933927
)
934928

935-
if valid_access_token:
936-
pass
937-
938-
elif (
939-
not current_user.is_authenticated
940-
and not CONFIG.TESTING
941-
and doc["type"] != "starting_materials"
942-
):
943-
return (
944-
jsonify(
945-
{
946-
"status": "error",
947-
"message": "Authentication required or invalid access token.",
948-
}
949-
),
950-
401,
951-
)
952-
953929
# determine the item type and validate according to the appropriate schema
954930
try:
955931
ItemModel = ITEM_MODELS[doc["type"]]

webapp/src/components/QRCode.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export default {
177177
}
178178
},
179179
hasExistingToken() {
180-
return this.tokenInfo && this.publicToken && this.publicToken !== "existing-token";
180+
return this.tokenInfo && this.publicToken === "existing-token";
181181
},
182182
},
183183
mounted() {
@@ -209,8 +209,7 @@ export default {
209209
if (response.ok && data.status === "success") {
210210
if (data.has_token) {
211211
this.tokenInfo = data.token_info;
212-
this.isPublicMode = true;
213-
this.publicToken = data.token_info.token;
212+
this.publicToken = "existing-token";
214213
}
215214
} else if (response.status === 404) {
216215
console.debug("No access to item or item not found");

webapp/src/components/TokenTable.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
<tbody>
1515
<tr v-if="isLoading">
1616
<td colspan="6" class="text-center">
17-
<div class="spinner-border spinner-border-sm" role="status">
18-
<span class="visually-hidden">Loading...</span>
19-
</div>
17+
<div class="spinner-border spinner-border-sm" role="status"></div>
2018
Loading tokens...
2119
</td>
2220
</tr>

webapp/src/views/EditPage.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</div>
9292
</div>
9393

94-
<FileSelectModal v-if="isAuthenticated" :item_id="item_id" />
94+
<FileSelectModal :item_id="item_id" />
9595
</div>
9696
</template>
9797

@@ -212,9 +212,6 @@ export default {
212212
itemApiUrl() {
213213
return API_URL + "/items/" + this.refcode;
214214
},
215-
isAuthenticated() {
216-
return this.$store.state.currentUserID != null;
217-
},
218215
},
219216
watch: {
220217
// add a warning before leaving page if unsaved

0 commit comments

Comments
 (0)