Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(links): allow direct access to spaces via public links; add file preview/edit/download; improve password validation

johaven5102e9ae6b17
diff --git a/backend/src/applications/links/constants/routes.ts b/backend/src/applications/links/constants/routes.ts
index caa22cf7..f71c624d 100644
--- a/backend/src/applications/links/constants/routes.ts
+++ b/backend/src/applications/links/constants/routes.ts
@@ -11,9 +11,11 @@ export const PUBLIC_LINKS_ROUTE = {
LINK: 'link',
VALIDATION: 'validation',
ACCESS: 'access',
+ DOWNLOAD: 'download',
AUTH: 'auth'
}
export const API_PUBLIC_LINK_VALIDATION = `${PUBLIC_LINKS_ROUTE.BASE}/${PUBLIC_LINKS_ROUTE.VALIDATION}`
export const API_PUBLIC_LINK_ACCESS = `${PUBLIC_LINKS_ROUTE.BASE}/${PUBLIC_LINKS_ROUTE.ACCESS}`
+export const API_PUBLIC_LINK_DOWNLOAD = `${PUBLIC_LINKS_ROUTE.BASE}/${PUBLIC_LINKS_ROUTE.DOWNLOAD}`
export const API_PUBLIC_LINK_AUTH = `${PUBLIC_LINKS_ROUTE.BASE}/${PUBLIC_LINKS_ROUTE.AUTH}`
diff --git a/backend/src/applications/links/interfaces/link-space.interface.ts b/backend/src/applications/links/interfaces/link-space.interface.ts
index 83053c0e..bd904bd6 100644
--- a/backend/src/applications/links/interfaces/link-space.interface.ts
+++ b/backend/src/applications/links/interfaces/link-space.interface.ts
@@ -4,8 +4,20 @@
* See the LICENSE file for licensing details
*/
+import type { FileEditorProvider } from '../../../configuration/config.interfaces'
+
export interface SpaceLink {
- share?: { name: string; alias: string; hasParent: boolean; isDir: boolean; mime: string }
- space?: { name: string; alias: string }
- owner?: { login?: string; fullName: string; avatar?: string }
+ share?: {
+ name: string
+ alias: string
+ hasParent: boolean
+ isDir: boolean
+ mtime: number
+ mime: string
+ size: number
+ permissions: string
+ } | null
+ space?: { name: string; alias: string } | null
+ owner?: { login?: string; fullName: string; avatar?: string } | null
+ fileEditors?: FileEditorProvider
}
diff --git a/backend/src/applications/links/links.controller.ts b/backend/src/applications/links/links.controller.ts
index feb5e213..945ced35 100644
--- a/backend/src/applications/links/links.controller.ts
+++ b/backend/src/applications/links/links.controller.ts
@@ -18,7 +18,7 @@ import { LinksManager } from './services/links-manager.service'
@Controller(PUBLIC_LINKS_ROUTE.BASE)
@AuthTokenOptional()
export class LinksController {
- constructor(private readonly linksPublicManager: LinksManager) {}
+ constructor(private readonly linksManager: LinksManager) {}
@Get(`${PUBLIC_LINKS_ROUTE.VALIDATION}/:uuid`)
linkValidation(
@@ -29,7 +29,7 @@ export class LinksController {
ok: boolean
link: SpaceLink
}> {
- return this.linksPublicManager.linkValidation(user, uuid)
+ return this.linksManager.linkValidation(user, uuid)
}
@Get(`${PUBLIC_LINKS_ROUTE.ACCESS}/:uuid`)
@@ -38,8 +38,18 @@ export class LinksController {
@Param('uuid') uuid: string,
@Req() req: FastifyRequest,
@Res({ passthrough: true }) res: FastifyReply
- ): Promise<StreamableFile | LoginResponseDto> {
- return this.linksPublicManager.linkAccess(user, uuid, req, res)
+ ): Promise<LoginResponseDto | Omit<LoginResponseDto, 'token'>> {
+ return this.linksManager.linkAccess(user, uuid, req, res)
+ }
+
+ @Get(`${PUBLIC_LINKS_ROUTE.DOWNLOAD}/:uuid`)
+ linkDownload(
+ @GetUser() user: UserModel,
+ @Param('uuid') uuid: string,
+ @Req() req: FastifyRequest,
+ @Res({ passthrough: true }) res: FastifyReply
+ ): Promise<StreamableFile> {
+ return this.linksManager.linkDownload(user, uuid, req, res)
}
@Post(`${PUBLIC_LINKS_ROUTE.AUTH}/:uuid`)
@@ -50,6 +60,6 @@ export class LinksController {
@Req() req: FastifyRequest,
@Res({ passthrough: true }) res: FastifyReply
): Promise<LoginResponseDto> {
- return this.linksPublicManager.linkAuthentication(user, uuid, linkPasswordDto, req, res)
+ return this.linksManager.linkAuthentication(user, uuid, linkPasswordDto, req, res)
}
}
diff --git a/backend/src/applications/links/services/links-manager.service.spec.ts b/backend/src/applications/links/services/links-manager.service.spec.ts
index 73bb58aa..3c824c3b 100644
--- a/backend/src/applications/links/services/links-manager.service.spec.ts
+++ b/backend/src/applications/links/services/links-manager.service.spec.ts
@@ -196,7 +196,6 @@ describe(LinksManager.name, () => {
share: { isDir: false, name: 'file.txt', alias: 'share-alias' }
} as any
linksQueriesMock.spaceLink.mockResolvedValueOnce(spaceLink)
-
spacesManagerMock.spaceEnv.mockResolvedValueOnce({} as any)
const streamable: any = { some: 'stream' }
filesManagerMock.sendFileFromSpace.mockReturnValueOnce({
@@ -208,7 +207,7 @@ describe(LinksManager.name, () => {
const logErrorSpy = jest.spyOn((service as any).logger, 'error').mockImplementation(() => undefined as any)
linksQueriesMock.incrementLinkNbAccess.mockRejectedValueOnce(new Error('increment boom'))
- const result = await service.linkAccess(identity, link.uuid, req, res)
+ const result = await service.linkDownload(identity, link.uuid, req, res)
expect(result).toBe(streamable)
expect(filesManagerMock.sendFileFromSpace).toHaveBeenCalled()
@@ -270,7 +269,7 @@ describe(LinksManager.name, () => {
const result = await service.linkAccess(sameUserIdentity as any, link.uuid, req, res)
- expect(result).toBeUndefined()
+ expect(result.user.id).toEqual(baseLink.user.id)
expect(authManagerMock.setCookies).not.toHaveBeenCalled()
expect(linksQueriesMock.incrementLinkNbAccess).not.toHaveBeenCalled()
})
@@ -282,6 +281,7 @@ describe(LinksManager.name, () => {
space: null,
share: { isDir: false, name: 'bad.txt', alias: 'share' }
} as any
+ linksQueriesMock.spaceLink.mockReset()
linksQueriesMock.spaceLink.mockResolvedValueOnce(spaceLink)
spacesManagerMock.spaceEnv.mockResolvedValueOnce({} as any)
@@ -290,7 +290,7 @@ describe(LinksManager.name, () => {
stream: jest.fn()
} as any)
- await expect(service.linkAccess(identity, link.uuid, req, res)).rejects.toMatchObject({
+ await expect(service.linkDownload(identity, link.uuid, req, res)).rejects.toMatchObject({
status: 500
})
expect(linksQueriesMock.incrementLinkNbAccess).toHaveBeenCalledWith(link.uuid)
diff --git a/backend/src/applications/links/services/links-manager.service.ts b/backend/src/applications/links/services/links-manager.service.ts
index 62ec8def..30092543 100644
--- a/backend/src/applications/links/services/links-manager.service.ts
+++ b/backend/src/applications/links/services/links-manager.service.ts
@@ -9,6 +9,7 @@ import { FastifyReply, FastifyRequest } from 'fastify'
import { LoginResponseDto } from '../../../authentication/dto/login-response.dto'
import { JwtIdentityPayload } from '../../../authentication/interfaces/jwt-payload.interface'
import { AuthManager } from '../../../authentication/services/auth-manager.service'
+import { serverConfig } from '../../../configuration/config.environment'
import { FilesManager } from '../../files/services/files-manager.service'
import { SendFile } from '../../files/utils/send-file'
import { SPACE_REPOSITORY } from '../../spaces/constants/spaces'
@@ -41,43 +42,67 @@ export class LinksManager {
this.logger.warn(`${this.linkValidation.name} - ${uuid} : ${check}`)
}
const spaceLink: SpaceLink = ok ? await this.linksQueries.spaceLink(uuid) : null
- if (spaceLink?.owner?.login) {
- spaceLink.owner.avatar = await getAvatarBase64(spaceLink.owner.login)
- // for security reasons
- delete spaceLink.owner.login
+ if (ok) {
+ if (spaceLink?.owner?.login) {
+ spaceLink.owner.avatar = await getAvatarBase64(spaceLink.owner.login)
+ // For security reasons
+ delete spaceLink.owner.login
+ }
+ if (spaceLink?.share) {
+ // Only used when the link is a file or a directory
+ spaceLink.fileEditors = serverConfig.fileEditors
+ }
}
return { ok: ok, error: ok ? null : check, link: spaceLink }
}
- async linkAccess(identity: JwtIdentityPayload, uuid: string, req: FastifyRequest, res: FastifyReply): Promise<StreamableFile | LoginResponseDto> {
+ async linkAccess(
+ identity: JwtIdentityPayload,
+ uuid: string,
+ req: FastifyRequest,
+ res: FastifyReply
+ ): Promise<LoginResponseDto | Omit<LoginResponseDto, 'token'>> {
const [link, check, ok] = await this.linkEnv(identity, uuid)
if (!ok) {
this.logger.warn(`${this.linkAccess.name} - *${link.user.login}* (${link.user.id}) : ${check}`)
throw new HttpException(check as string, HttpStatus.BAD_REQUEST)
}
const user = new UserModel(link.user)
- const spaceLink: SpaceLink = await this.linksQueries.spaceLink(uuid)
- if (!spaceLink.space && !spaceLink.share.isDir) {
- // download the file (authentication has been verified before)
- this.logger.log(`${this.linkAccess.name} - *${user.login}* (${user.id}) downloading ${spaceLink.share.name}`)
- this.incrementLinkNbAccess(link)
- const spaceEnv: SpaceEnv = await this.spaceEnvFromLink(user, spaceLink)
- const sendFile: SendFile = this.filesManager.sendFileFromSpace(spaceEnv, spaceLink.share.name)
- try {
- await sendFile.checks()
- return await sendFile.stream(req, res)
- } catch (e) {
- this.logger.error(`${this.linkAccess.name} - unable to send file : ${e}`)
- throw new HttpException('Unable to download file', HttpStatus.INTERNAL_SERVER_ERROR)
- }
- } else if (link.user.id !== identity.id) {
- // authenticate user to allow access to the directory
+ if (link.user.id !== identity.id) {
+ // Authenticate user to allow access to the directory
this.logger.log(`${this.linkAccess.name} - *${user.login}* (${user.id}) is logged`)
this.incrementLinkNbAccess(link)
this.usersManager.updateAccesses(user, req.ip, true).catch((e: Error) => this.logger.error(`${this.linkAccess.name} - ${e}`))
return this.authManager.setCookies(user, res)
}
- // already authenticated
+ // Already authenticated
+ return { user: user, server: serverConfig }
+ }
+
+ async linkDownload(identity: JwtIdentityPayload, uuid: string, req: FastifyRequest, res: FastifyReply): Promise<StreamableFile> {
+ const [link, check, ok] = await this.linkEnv(identity, uuid)
+ if (!ok) {
+ this.logger.warn(`${this.linkDownload.name} - *${link.user.login}* (${link.user.id}) : ${check}`)
+ throw new HttpException(check as string, HttpStatus.BAD_REQUEST)
+ }
+ const spaceLink: SpaceLink = await this.linksQueries.spaceLink(uuid)
+ if (spaceLink.space || spaceLink.share?.isDir) {
+ this.logger.error(`${this.linkDownload.name} - the provided link does not reference a downloadable file`)
+ throw new HttpException('This link does not allow file download', HttpStatus.BAD_REQUEST)
+ }
+ const user = new UserModel(link.user)
+ // Download the file (authentication has been verified before)
+ this.logger.log(`${this.linkDownload.name} - *${user.login}* (${user.id}) downloading ${spaceLink.share.name}`)
+ this.incrementLinkNbAccess(link)
+ const spaceEnv: SpaceEnv = await this.spaceEnvFromLink(user, spaceLink)
+ const sendFile: SendFile = this.filesManager.sendFileFromSpace(spaceEnv, spaceLink.share.name)
+ try {
+ await sendFile.checks()
+ return await sendFile.stream(req, res)
+ } catch (e) {
+ this.logger.error(`${this.linkDownload.name} - unable to send file : ${e}`)
+ throw new HttpException('Unable to download file', HttpStatus.INTERNAL_SERVER_ERROR)
+ }
}
async linkAuthentication(identity: JwtIdentityPayload, uuid: string, linkPasswordDto: UserPasswordDto, req: FastifyRequest, res: FastifyReply) {
diff --git a/backend/src/applications/links/services/links-queries.service.ts b/backend/src/applications/links/services/links-queries.service.ts
index 149c3c2f..103a33ba 100644
--- a/backend/src/applications/links/services/links-queries.service.ts
+++ b/backend/src/applications/links/services/links-queries.service.ts
@@ -155,7 +155,10 @@ export class LinksQueries {
alias: shares.alias,
hasParent: isNotNull(shares.parentId).mapWith(Boolean),
isDir: sql`IF (${isNotNull(shares.externalPath)} OR ${isNotNull(shareSpaceRoot.externalPath)}, 1 ,${files.isDir})`.mapWith(Boolean),
- mime: files.mime
+ mime: files.mime,
+ mtime: files.mtime,
+ size: files.size,
+ permissions: sharesMembers.permissions
},
space: { name: spaces.name, alias: spaces.alias },
owner: { login: shareOwner.login, fullName: userFullNameSQL(shareOwner) }
@@ -176,7 +179,11 @@ export class LinksQueries {
)
.where(eq(links.uuid, uuid))
.limit(1)
- return r
+ return {
+ ...r,
+ space: r.space?.name ? r.space : null,
+ share: r.share?.name ? r.share : null
+ }
}
async incrementLinkNbAccess(uuid: string) {
diff --git a/frontend/src/app/applications/links/components/public/public-link-auth.component.html b/frontend/src/app/applications/links/components/public/public-link-auth.component.html
index 34c7bd5e..30e5d49c 100644
--- a/frontend/src/app/applications/links/components/public/public-link-auth.component.html
+++ b/frontend/src/app/applications/links/components/public/public-link-auth.component.html
@@ -10,19 +10,20 @@
<img alt="" height="40" [src]="logoUrl">
</a>
</div>
- <img (click)="validPassword()" alt="" class="cursor-pointer" [src]="linkProtected" height="96">
- <div class="d-flex mt-2 ms-auto me-auto" style="width: 250px">
- <div class="input-group">
- <span class="input-group-text bg-gray-light">
- <fa-icon [icon]="icons.faKey"></fa-icon>
- </span>
+ <div class="d-flex flex-column align-items-center" style="margin: 1.2rem 1rem;">
+ <img (click)="validPassword()" alt="" class="cursor-pointer" [src]="linkProtected" height="96">
+ </div>
+ <div class="d-flex flex-column align-items-center mt-2 ms-auto me-auto">
+ <div class="input-group" style="max-width: 200px">
<input [(ngModel)]="password"
(keyup.enter)="validPassword()"
+ [class.is-invalid]="password?.length < passwordMinLength"
autocomplete="off"
class="form-control border-0"
[placeholder]="'Password' | translate:locale.language"
- type="password">
- <button [disabled]="!password?.length"
+ type="password"
+ required>
+ <button [disabled]="password?.length < passwordMinLength"
(click)="validPassword()"
class="btn btn-default btn-custom border-0"
type="button">
@@ -33,7 +34,7 @@
<div class="error-text no-select">
<span class="hr"></span>
<div>
- <span class="solve" l10nTranslate>This share is protected by a password</span>
+ <span class="solve" l10nTranslate>This access is protected by a password</span>
</div>
</div>
</div>
diff --git a/frontend/src/app/applications/links/components/public/public-link-auth.component.ts b/frontend/src/app/applications/links/components/public/public-link-auth.component.ts
index 813a50b6..1248dcb3 100644
--- a/frontend/src/app/applications/links/components/public/public-link-auth.component.ts
+++ b/frontend/src/app/applications/links/components/public/public-link-auth.component.ts
@@ -9,6 +9,7 @@ import { FormsModule } from '@angular/forms'
import { ActivatedRoute, Params, RouterLink } from '@angular/router'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faKey, faSignInAlt } from '@fortawesome/free-solid-svg-icons'
+import { USER_PASSWORD_MIN_LENGTH } from '@sync-in-server/backend/src/applications/users/constants/user'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'
import { linkProtected, logoUrl } from '../../../files/files.constants'
import { LinksService } from '../../services/links.service'
@@ -23,6 +24,7 @@ export class PublicLinkAuthComponent {
protected readonly logoUrl = logoUrl
protected readonly linkProtected = linkProtected
protected readonly icons = { faKey, faSignInAlt }
+ protected readonly passwordMinLength = USER_PASSWORD_MIN_LENGTH
protected password = ''
private readonly activatedRoute = inject(ActivatedRoute)
private readonly linksService = inject(LinksService)
@@ -33,7 +35,7 @@ export class PublicLinkAuthComponent {
}
validPassword() {
- if (this.password) {
+ if (this.password && this.password.length >= this.passwordMinLength) {
this.linksService.linkAuthentication(this.uuid, this.password).subscribe(() => (this.password = ''))
}
}
diff --git a/frontend/src/app/applications/links/components/public/public-link-error.component.html b/frontend/src/app/applications/links/components/public/public-link-error.component.html
index 28279d87..8ad22ab5 100644
--- a/frontend/src/app/applications/links/components/public/public-link-error.component.html
+++ b/frontend/src/app/applications/links/components/public/public-link-error.component.html
@@ -10,13 +10,14 @@
<img alt="" height="40" [src]="logoUrl">
</a>
</div>
- <fa-icon class="text-white" [icon]="icons.faExclamationCircle" size="4x"></fa-icon>
- <div class="error-code mt-2" style="font-size: 24px" l10nTranslate>Link error</div>
+ <div class="d-flex flex-column align-items-center" style="margin-top: 1.2rem; margin-bottom: .6rem">
+ <fa-icon class="text-white" [icon]="icons.faExclamationCircle" size="5x"></fa-icon>
+ </div>
+ <div class="error-code" l10nTranslate>Link error</div>
<div class="error-text">
<span class="hr"></span>
- <br>
- <span l10nTranslate>{{ error }}</span>
- <br>
- <br>
+ <div>
+ <span class="solve" l10nTranslate>{{ error }}</span>
+ </div>
</div>
</div>
diff --git a/frontend/src/app/applications/links/components/public/public-link.component.html b/frontend/src/app/applications/links/components/public/public-link.component.html
index 977fd593..90cc0985 100644
--- a/frontend/src/app/applications/links/components/public/public-link.component.html
+++ b/frontend/src/app/applications/links/components/public/public-link.component.html
@@ -11,13 +11,29 @@
</a>
</div>
<div class="d-flex flex-column align-content-center">
- <div (click)="followLink()" class="resource d-flex flex-column align-items-center mt-3 mx-auto cursor-pointer">
- @if (mimeUrl) {
- <img [src]="mimeUrl" alt="" height="96" class="no-select-pointer" (error)="fallBackMimeUrl()">
- } @else {
- <fa-icon [icon]="icons.SPACES" class="circle-primary-icon" [fixedWidth]="false" style="min-width: 128px; min-height: 128px; font-size: 64px"></fa-icon>
+ <div class="d-flex flex-column align-items-center mt-3 mb-1 mx-auto cursor-pointer">
+ <div (click)="followLink()" class="resource">
+ <div class="mime">
+ @if (file?.mimeUrl) {
+ <img [src]="file.mimeUrl" alt="" height="96" class="no-select-pointer" (error)="fallBackMimeUrl()">
+ } @else {
+ <fa-icon [icon]="icons.SPACES" class="circle-primary-icon" [fixedWidth]="false" style="width: 96px; height: 96px; font-size: 48px"></fa-icon>
+ }
+ </div>
+ <span class="error-code">{{ link.share?.name || link.space?.name }}</span>
+ </div>
+ @if (file?.isDir === false) {
+ <div class="mt-3 mb-2 fs-lg">
+ @if (file?.isViewable) {
+ <button (click)="openLink()" class="btn btn-lg btn-outline-light me-2" l10nTranslate>
+ <fa-icon [icon]="fileCanBeModified && file.isEditable ? icons.faPen : icons.faEye"></fa-icon>
+ </button>
+ }
+ <button (click)="downloadLink()" class="btn btn-lg btn-outline-light">
+ <fa-icon [icon]="icons.faDownload"></fa-icon>
+ </button>
+ </div>
}
- <span class="error-code">{{ link.share?.name || link.space?.name }}</span>
</div>
</div>
<div class="error-text no-select">
diff --git a/frontend/src/app/applications/links/components/public/public-link.component.ts b/frontend/src/app/applications/links/components/public/public-link.component.ts
index c5968819..cb81f64a 100644
--- a/frontend/src/app/applications/links/components/public/public-link.component.ts
+++ b/frontend/src/app/applications/links/components/public/public-link.component.ts
@@ -7,9 +7,12 @@
import { Component, inject } from '@angular/core'
import { ActivatedRoute, Data, Params, RouterLink } from '@angular/router'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
-import { SpaceLink } from '@sync-in-server/backend/src/applications/links/interfaces/link-space.interface'
+import { faDownload, faEye, faPen } from '@fortawesome/free-solid-svg-icons'
+import type { SpaceLink } from '@sync-in-server/backend/src/applications/links/interfaces/link-space.interface'
+import { SPACE_OPERATION, SPACE_REPOSITORY } from '@sync-in-server/backend/src/applications/spaces/constants/spaces'
import { L10N_LOCALE, L10nLocale, L10nTranslateDirective, L10nTranslatePipe } from 'angular-l10n'
-import { defaultMimeUrl, getAssetsMimeUrl, logoUrl, mimeDirectory, mimeDirectoryShare } from '../../../files/files.constants'
+import { logoUrl } from '../../../files/files.constants'
+import { FileModel } from '../../../files/models/file.model'
import { SPACES_ICON } from '../../../spaces/spaces.constants'
import { LinksService } from '../../services/links.service'
@@ -20,9 +23,10 @@ import { LinksService } from '../../services/links.service'
})
export class PublicLinkComponent {
protected readonly locale = inject<L10nLocale>(L10N_LOCALE)
- protected readonly icons = { SPACES: SPACES_ICON.SPACES }
+ protected readonly icons = { SPACES: SPACES_ICON.SPACES, faEye, faDownload, faPen }
protected readonly logoUrl = logoUrl
- protected mimeUrl: string = null
+ protected file: FileModel
+ protected fileCanBeModified: boolean
protected link: SpaceLink
private readonly activatedRoute = inject(ActivatedRoute)
private readonly linksService = inject(LinksService)
@@ -33,18 +37,41 @@ export class PublicLinkComponent {
this.activatedRoute.data.subscribe((data: Data) => this.setLink(data.link))
}
- setLink(link: SpaceLink) {
- if (!link.space) {
- this.mimeUrl = getAssetsMimeUrl(link.share.isDir ? (link.share.hasParent ? mimeDirectoryShare : mimeDirectory) : link.share.mime)
- }
- this.link = link
+ openLink() {
+ this.linksService.linkAccessOrView(this.linkUUID, this.link, this.file)
+ }
+
+ downloadLink() {
+ this.linksService.linkDownload(this.linkUUID)
}
followLink() {
- this.linksService.linkAccess(this.linkUUID, this.link)
+ this.linksService.linkAccessOrView(this.linkUUID, this.link)
}
fallBackMimeUrl() {
- this.mimeUrl = defaultMimeUrl
+ this.file.fallBackMimeUrl()
+ }
+
+ private setLink(link: SpaceLink) {
+ if (!link.space) {
+ this.file = new FileModel(
+ {
+ id: -1,
+ name: link.share.name,
+ path: '',
+ isDir: link.share.isDir,
+ size: link.share.size,
+ mime: link.share.mime,
+ mtime: link.share.mtime,
+ root: { alias: link.share.alias }
+ } as FileModel,
+ SPACE_REPOSITORY.SHARES,
+ link.share.hasParent,
+ link.fileEditors
+ )
+ this.fileCanBeModified = link.share.permissions.indexOf(SPACE_OPERATION.MODIFY) > -1
+ }
+ this.link = link
}
}
diff --git a/frontend/src/app/applications/links/services/links.service.ts b/frontend/src/app/applications/links/services/links.service.ts
index 9fff5ca5..30fe6aab 100644
--- a/frontend/src/app/applications/links/services/links.service.ts
+++ b/frontend/src/app/applications/links/services/links.service.ts
@@ -11,6 +11,7 @@ import { LINK_ERROR, LINK_TYPE } from '@sync-in-server/backend/src/applications/
import {
API_PUBLIC_LINK_ACCESS,
API_PUBLIC_LINK_AUTH,
+ API_PUBLIC_LINK_DOWNLOAD,
API_PUBLIC_LINK_VALIDATION
} from '@sync-in-server/backend/src/applications/links/constants/routes'
import type { CreateOrUpdateLinkDto } from '@sync-in-server/backend/src/applications/links/dto/create-or-update-link.dto'
@@ -33,6 +34,8 @@ import { take } from 'rxjs/operators'
import { AuthService } from '../../../auth/auth.service'
import { downloadWithAnchor } from '../../../common/utils/functions'
import { LayoutService } from '../../../layout/layout.service'
+import { FileModel } from '../../files/models/file.model'
+import { FilesService } from '../../files/services/files.service'
import type { ShareModel } from '../../shares/models/share.model'
import type { SpaceModel } from '../../spaces/models/space.model'
import { SPACES_PATH } from '../../spaces/spaces.constants'
@@ -50,6 +53,7 @@ export class LinksService {
private readonly layout = inject(LayoutService)
private readonly authService = inject(AuthService)
private readonly clipboard = inject(ClipboardService)
+ private readonly filesService = inject(FilesService)
shareLinksList(): Observable<ShareLinkModel[]> {
return this.http.get<ShareLinkModel[]>(API_SHARES_LINKS_LIST).pipe(map((sls: Partial<ShareLinkModel>[]) => sls.map((s) => new ShareLinkModel(s))))
@@ -91,19 +95,31 @@ export class LinksService {
)
}
- linkAccess(uuid: string, link: SpaceLink) {
- if (link.share?.isDir || link.space?.alias) {
- this.http.get<LoginResponseDto>(`${API_PUBLIC_LINK_ACCESS}/${uuid}`).subscribe((r) => {
+ linkAccessOrView(uuid: string, link: SpaceLink, fileToView?: FileModel) {
+ this.http.get<LoginResponseDto>(`${API_PUBLIC_LINK_ACCESS}/${uuid}`).subscribe((r) => {
+ if (!r.token) {
+ // Already authenticated
+ this.authService.initUser(r)
+ } else {
+ // First authentication with token
this.authService.initUserFromResponse(r)
- if (link.space) {
- this.router.navigate([SPACES_PATH.SPACES, link.space.alias]).catch(console.error)
- } else {
+ }
+ if (fileToView) {
+ this.filesService.openViewerDialog(fileToView, [], link.share.permissions).catch(console.error)
+ } else if (link.space) {
+ this.router.navigate([SPACES_PATH.SPACES_FILES, link.space.alias]).catch(console.error)
+ } else {
+ if (link.share.isDir) {
this.router.navigate([SPACES_PATH.SPACES_SHARES, link.share.alias]).catch(console.error)
+ } else {
+ this.router.navigate([SPACES_PATH.SPACES_SHARES], { queryParams: { select: link.share.alias } }).catch(console.error)
}
- })
- } else {
- downloadWithAnchor(`${API_PUBLIC_LINK_ACCESS}/${uuid}`)
- }
+ }
+ })
+ }
+
+ linkDownload(uuid: string) {
+ downloadWithAnchor(`${API_PUBLIC_LINK_DOWNLOAD}/${uuid}`)
}
linkAuthentication(uuid: string, password: string): Observable<boolean> {
@@ -115,7 +131,7 @@ export class LinksService {
}),
catchError((e) => {
if (e.error.message === LINK_ERROR.UNAUTHORIZED) {
- this.layout.sendNotification('warning', 'Link', 'Bad password')
+ this.layout.sendNotification('error', 'Link', 'Bad password')
} else {
this.router.navigate([`${LINKS_PATH.LINK}/${uuid}/${e.error.message}`]).catch(console.error)
}
diff --git a/frontend/src/app/auth/auth.service.ts b/frontend/src/app/auth/auth.service.ts
index bf755249..a60646e8 100644
--- a/frontend/src/app/auth/auth.service.ts
+++ b/frontend/src/app/auth/auth.service.ts
@@ -187,7 +187,7 @@ export class AuthService {
)
}
- checkUserAuthAndLoad(returnUrl: string) {
+ checkUserAuthAndLoad(returnUrl: string): Observable<boolean> {
if (this.refreshTokenHasExpired()) {
if (this.electron.enabled) {
return this.loginElectron()
diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json
index af23ea32..4e41b572 100644
--- a/frontend/src/i18n/de.json
+++ b/frontend/src/i18n/de.json
@@ -243,7 +243,7 @@
"The location is not writeable": "Der Speicherort ist nicht beschreibbar",
"The location is a directory": "Der Speicherort ist ein Verzeichnis",
"The file is locked": "Die Datei ist gesperrt",
- "This share is protected by a password": "Diese Freigabe ist durch ein Passwort geschützt",
+ "This access is protected by a password": "Dieser Zugriff ist durch ein Passwort geschützt",
"You do not have share permission": "Sie haben keine Berechtigung zum Freigeben",
"You can not share a space": "Sie können keinen Bereich freigeben",
"You can not remove an anchored file": "Sie können eine angeheftete Datei nicht entfernen",
diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.json
index e2a3613b..78548c13 100644
--- a/frontend/src/i18n/es.json
+++ b/frontend/src/i18n/es.json
@@ -243,7 +243,7 @@
"The location is not writeable": "La ubicación no es escribible",
"The location is a directory": "La ubicación es un directorio",
"The file is locked": "El archivo está bloqueado",
- "This share is protected by a password": "Este compartido está protegido por una contraseña",
+ "This access is protected by a password": "Este acceso está protegido por una contraseña",
"You do not have share permission": "No tiene permiso para compartir",
"You can not share a space": "No puede compartir un espacio",
"You can not remove an anchored file": "No puede eliminar un archivo anclado",
diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.json
index c5f29036..9f1a6891 100644
--- a/frontend/src/i18n/fr.json
+++ b/frontend/src/i18n/fr.json
@@ -243,7 +243,7 @@
"The location is not writeable": "L'emplacement n'est pas accessible en écriture",
"The location is a directory": "L'emplacement est un répertoire",
"The file is locked": "Le fichier est verrouillé",
- "This share is protected by a password": "Ce partage est protégé par un mot de passe",
+ "This access is protected by a password": "Cet accès est protégé par un mot de passe",
"You do not have share permission": "Vous n'avez pas la permission de partager",
"You can not share a space": "Vous ne pouvez pas partager un espace",
"You can not remove an anchored file": "vous ne pouvez pas supprimer un fichier ancré",
diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.json
index 356e961f..68fe545e 100644
--- a/frontend/src/i18n/hi.json
+++ b/frontend/src/i18n/hi.json
@@ -243,7 +243,7 @@
"The location is not writeable": "स्थान लिखने योग्य नहीं है",
"The location is a directory": "स्थान एक निर्देशिका है",
"The file is locked": "फ़ाइल लॉक है",
- "This share is protected by a password": "यह साझाकरण पासवर्ड से संरक्षित है",
+ "This access is protected by a password": "यह एक्सेस पासवर्ड से संरक्षित है",
"You do not have share permission": "आपके पास साझा करने की अनुमति नहीं है",
"You can not share a space": "आप किसी स्पेस को साझा नहीं कर सकते",
"You can not remove an anchored file": "आप एंकर की गई फ़ाइल नहीं हटा सकते",
diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.json
index 0ae8797f..24d61b86 100644
--- a/frontend/src/i18n/it.json
+++ b/frontend/src/i18n/it.json
@@ -243,7 +243,7 @@
"The location is not writeable": "La posizione non è scrivibile",
"The location is a directory": "La posizione è una directory",
"The file is locked": "Il file è bloccato",
- "This share is protected by a password": "Questa condivisione è protetta da password",
+ "This access is protected by a password": "Questo accesso è protetto da password",
"You do not have share permission": "Non hai il permesso di condividere",
"You can not share a space": "Non puoi condividere uno spazio",
"You can not remove an anchored file": "Non puoi rimuovere un file ancorato",
diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.json
index f2d7e6d6..d77e372d 100644
--- a/frontend/src/i18n/ja.json
+++ b/frontend/src/i18n/ja.json
@@ -243,7 +243,7 @@
"The location is not writeable": "その場所は書き込み不可です",
"The location is a directory": "その場所はディレクトリです",
"The file is locked": "ファイルはロックされています",
- "This share is protected by a password": "この共有はパスワードで保護されています",
+ "This access is protected by a password": "このアクセスはパスワードで保護されています",
"You do not have share permission": "共有する権限がありません",
"You can not share a space": "スペースは共有できません",
"You can not remove an anchored file": "アンカーされたファイルは削除できません",
diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.json
index 3b072852..11028218 100644
--- a/frontend/src/i18n/ko.json
+++ b/frontend/src/i18n/ko.json
@@ -243,7 +243,7 @@
"The location is not writeable": "해당 위치는 쓰기 불가입니다",
"The location is a directory": "해당 위치는 디렉터리입니다",
"The file is locked": "파일이 잠겨 있습니다",
- "This share is protected by a password": "이 공유는 비밀번호로 보호됩니다",
+ "This access is protected by a password": "이 액세스는 비밀번호로 보호됩니다",
"You do not have share permission": "공유할 권한이 없습니다",
"You can not share a space": "스페이스는 공유할 수 없습니다",
"You can not remove an anchored file": "고정된 파일은 삭제할 수 없습니다",
diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.json
index 658e40d2..a48fca1f 100644
--- a/frontend/src/i18n/pl.json
+++ b/frontend/src/i18n/pl.json
@@ -243,7 +243,7 @@
"The location is not writeable": "Lokalizacja nie jest zapisywalna",
"The location is a directory": "Lokalizacja jest katalogiem",
"The file is locked": "Plik jest zablokowany",
- "This share is protected by a password": "To udostępnienie jest chronione hasłem",
+ "This access is protected by a password": "Ten dostęp jest chroniony hasłem",
"You do not have share permission": "Nie masz uprawnień do udostępniania",
"You can not share a space": "Nie możesz udostępnić przestrzeni",
"You can not remove an anchored file": "Nie możesz usunąć zakotwiczonego pliku",
diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.json
index ffa3955d..708911aa 100644
--- a/frontend/src/i18n/pt-BR.json
+++ b/frontend/src/i18n/pt-BR.json
@@ -243,7 +243,7 @@
"The location is not writeable": "O local não é gravável",
"The location is a directory": "O local é um diretório",
"The file is locked": "O arquivo está bloqueado",
- "This share is protected by a password": "Este compartilhamento é protegido por senha",
+ "This access is protected by a password": "Este acesso é protegido por senha",
"You do not have share permission": "Você não tem permissão para compartilhar",
"You can not share a space": "Você não pode compartilhar um espaço",
"You can not remove an anchored file": "Você não pode remover um arquivo ancorado",
diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.json
index 71e5687c..39fed5cb 100644
--- a/frontend/src/i18n/pt.json
+++ b/frontend/src/i18n/pt.json
@@ -243,7 +243,7 @@
"The location is not writeable": "A localização não é gravável",
"The location is a directory": "A localização é um diretório",
"The file is locked": "O arquivo está bloqueado",
- "This share is protected by a password": "Este compartilhamento está protegido por senha",
+ "This access is protected by a password": "Este acesso está protegido por senha",
"You do not have share permission": "Você não tem permissão para compartilhar",
"You can not share a space": "Você não pode compartilhar um espaço",
"You can not remove an anchored file": "Você não pode remover um arquivo ancorado",
diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.json
index 88639a00..70f2a06e 100644
--- a/frontend/src/i18n/ru.json
+++ b/frontend/src/i18n/ru.json
@@ -243,7 +243,7 @@
"The location is not writeable": "Расположение недоступно для записи",
"The location is a directory": "Расположение — это папка",
"The file is locked": "Файл заблокирован",
- "This share is protected by a password": "Этот общий доступ защищён паролем",
+ "This access is protected by a password": "Этот доступ защищён паролем",
"You do not have share permission": "У вас нет прав на предоставление общего доступа",
"You can not share a space": "Нельзя предоставить общий доступ к пространству",
"You can not remove an anchored file": "Нельзя удалить закреплённый файл",
diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.json
index 42cfe760..ebc962ed 100644
--- a/frontend/src/i18n/tr.json
+++ b/frontend/src/i18n/tr.json
@@ -243,7 +243,7 @@
"The location is not writeable": "Konuma yazılamıyor",
"The location is a directory": "Konum bir dizin",
"The file is locked": "Dosya kilitli",
- "This share is protected by a password": "Bu paylaşım parola ile korunuyor",
+ "This access is protected by a password": "Bu erişim parola ile korunuyor",
"You do not have share permission": "Paylaşma izniniz yok",
"You can not share a space": "Bir alanı paylaşamazsınız",
"You can not remove an anchored file": "Sabitlenmiş bir dosyayı kaldıramazsınız",
diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.json
index 356e153d..dd295daa 100644
--- a/frontend/src/i18n/zh.json
+++ b/frontend/src/i18n/zh.json
@@ -243,7 +243,7 @@
"The location is not writeable": "该位置不可写",
"The location is a directory": "该位置是一个目录",
"The file is locked": "文件已锁定",
- "This share is protected by a password": "此共享受密码保护",
+ "This access is protected by a password": "此访问受密码保护",
"You do not have share permission": "您没有共享权限",
"You can not share a space": "您不能共享空间",
"You can not remove an anchored file": "您不能删除已锚定的文件",
diff --git a/frontend/src/styles/components/_links.scss b/frontend/src/styles/components/_links.scss
index 367aa531..3edd3406 100755
--- a/frontend/src/styles/components/_links.scss
+++ b/frontend/src/styles/components/_links.scss
@@ -14,19 +14,30 @@
.header {
background: #fff;
- padding: 15px 0;
+ padding: 10px 0;
-webkit-box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
- margin-bottom: 18px;
-
}
.resource {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-bottom: .3rem;
&:hover {
span {
@extend .text-gray;
}
}
+ .mime {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background-color: rgba(255, 255, 255, 0.2);
+ padding: .3rem;
+ border-radius: 1rem;
+ margin: .8rem;
+ }
}
.error-code {
@@ -34,7 +45,6 @@
color: #fff;
font-size: 20px;
font-weight: 700;
- margin-top: 10px;
text-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
line-height: normal;
}
@@ -54,7 +64,7 @@
background: rgba(0, 0, 0, 0.2);
display: inline-block;
height: 5px;
- margin: 25px 0 10px 0;
+ margin: 15px 0 5px 0;
width: 40px;
}