mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
refactor: shared collection controller
This commit is contained in:
@@ -61,7 +61,16 @@ export class CollectionService {
|
||||
.delete();
|
||||
}
|
||||
|
||||
getAuthContext() {
|
||||
getPublicCollectionById(id: Collection['id']) {
|
||||
return Collection.query()
|
||||
.where('id', id)
|
||||
.andWhere('visibility', Visibility.PUBLIC)
|
||||
.preload('links')
|
||||
.preload('author')
|
||||
.firstOrFail();
|
||||
}
|
||||
|
||||
private getAuthContext() {
|
||||
const context = HttpContext.getOrFail();
|
||||
if (!context.auth.user || !context.auth.user.id) {
|
||||
throw new Error('User not authenticated');
|
||||
|
||||
Reference in New Issue
Block a user