Skip to content

Commit

Permalink
fix: limit search results to boards belonging to the owner.
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqimei committed May 13, 2023
1 parent e39923d commit c9d515c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion imports/models/BoardCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ export class BoardCollectionClass extends BaseCollection<BoardRecord> {
}
}

public async searchBoard(searchTerm: string): Promise<SearchResults> {
public async searchBoard(userid: string, searchTerm: string): Promise<SearchResults> {
const query = {
userid,
$or: [
{
'elements.text': {
Expand Down
10 changes: 5 additions & 5 deletions imports/services/BoardService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IBoard } from '../excalidraw/types'
import { BoardCollection} from '../models'
import { Collections } from '../models/Collections'
import { IBoard } from '/imports/excalidraw/types'
import { BoardCollection } from '/imports/models'
import { Collections } from '/imports/models/Collections'
import { BaseService } from './BaseService'
import { Meteor } from 'meteor/meteor'
import { _makeBoard, _makeBoards } from '../utils/boards'
Expand Down Expand Up @@ -74,13 +74,13 @@ export class BoardService extends BaseService {
}
throw new Meteor.Error('Unauthorized')
}

public searchBoards(searchTerm: string) {
const userId = Meteor.userId()
if (userId == null) {
throw new Meteor.Error('Unauthorized')
}
const boards = BoardCollection.searchBoard(searchTerm)
const boards = BoardCollection.searchBoard(userId, searchTerm)
return boards
}
}
32 changes: 16 additions & 16 deletions package-lock.json

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

0 comments on commit c9d515c

Please sign in to comment.