mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
fix(frontend-config): use guest access level instead of allowAnonymous
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
56643ffd85
commit
1207ce7690
4 changed files with 17 additions and 9 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -8,8 +8,8 @@ import { HttpMethod } from '../../src/handler-utils/respond-to-matching-request'
|
||||||
|
|
||||||
declare namespace Cypress {
|
declare namespace Cypress {
|
||||||
interface Chainable {
|
interface Chainable {
|
||||||
loadConfig(additionalConfig?: Partial<typeof config>): Chainable<Window>,
|
loadConfig(additionalConfig?: Partial<typeof config>): Chainable<Window>
|
||||||
logIn: Chainable<Window>,
|
logIn: Chainable<Window>
|
||||||
logOut: Chainable<Window>
|
logOut: Chainable<Window>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,8 @@ export const authProviders = [
|
||||||
]
|
]
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
allowAnonymous: true,
|
|
||||||
allowRegister: true,
|
allowRegister: true,
|
||||||
|
guestAccess: 'write',
|
||||||
authProviders: authProviders,
|
authProviders: authProviders,
|
||||||
branding: branding,
|
branding: branding,
|
||||||
useImageProxy: false,
|
useImageProxy: false,
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export interface FrontendConfig {
|
export interface FrontendConfig {
|
||||||
allowAnonymous: boolean
|
|
||||||
allowRegister: boolean
|
allowRegister: boolean
|
||||||
authProviders: AuthProvider[]
|
authProviders: AuthProvider[]
|
||||||
branding: BrandingConfig
|
branding: BrandingConfig
|
||||||
|
guestAccess: GuestAccessLevel
|
||||||
useImageProxy: boolean
|
useImageProxy: boolean
|
||||||
specialUrls: SpecialUrls
|
specialUrls: SpecialUrls
|
||||||
version: BackendVersion
|
version: BackendVersion
|
||||||
|
@ -16,6 +16,13 @@ export interface FrontendConfig {
|
||||||
maxDocumentLength: number
|
maxDocumentLength: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum GuestAccessLevel {
|
||||||
|
DENY = 'deny',
|
||||||
|
READ = 'read',
|
||||||
|
WRITE = 'write',
|
||||||
|
CREATE = 'create'
|
||||||
|
}
|
||||||
|
|
||||||
export enum AuthProviderType {
|
export enum AuthProviderType {
|
||||||
DROPBOX = 'dropbox',
|
DROPBOX = 'dropbox',
|
||||||
FACEBOOK = 'facebook',
|
FACEBOOK = 'facebook',
|
||||||
|
|
|
@ -10,16 +10,17 @@ import { NewNoteButton } from '../../common/new-note-button/new-note-button'
|
||||||
import { HistoryButton } from '../../layout/app-bar/app-bar-elements/help-dropdown/history-button'
|
import { HistoryButton } from '../../layout/app-bar/app-bar-elements/help-dropdown/history-button'
|
||||||
import { useFrontendConfig } from '../../common/frontend-config-context/use-frontend-config'
|
import { useFrontendConfig } from '../../common/frontend-config-context/use-frontend-config'
|
||||||
import { Trans, useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
import { GuestAccessLevel } from '../../../api/config/types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the card with the options for not logged-in users.
|
* Renders the card with the options for not logged-in users.
|
||||||
*/
|
*/
|
||||||
export const GuestCard: React.FC = () => {
|
export const GuestCard: React.FC = () => {
|
||||||
const allowAnonymous = useFrontendConfig().allowAnonymous
|
const guestAccessLevel = useFrontendConfig().guestAccess
|
||||||
|
|
||||||
useTranslation()
|
useTranslation()
|
||||||
|
|
||||||
if (!allowAnonymous) {
|
if (guestAccessLevel === GuestAccessLevel.DENY) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import type { FrontendConfig } from '../../../api/config/types'
|
import type { FrontendConfig } from '../../../api/config/types'
|
||||||
import { AuthProviderType } from '../../../api/config/types'
|
import { AuthProviderType, GuestAccessLevel } from '../../../api/config/types'
|
||||||
import {
|
import {
|
||||||
HttpMethod,
|
HttpMethod,
|
||||||
respondToMatchingRequest,
|
respondToMatchingRequest,
|
||||||
|
@ -14,12 +14,12 @@ import { isTestMode } from '../../../utils/test-modes'
|
||||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
|
||||||
const initialConfig: FrontendConfig = {
|
const initialConfig: FrontendConfig = {
|
||||||
allowAnonymous: true,
|
|
||||||
allowRegister: true,
|
allowRegister: true,
|
||||||
branding: {
|
branding: {
|
||||||
name: 'DEMO Corp',
|
name: 'DEMO Corp',
|
||||||
logo: '/public/img/demo.png'
|
logo: '/public/img/demo.png'
|
||||||
},
|
},
|
||||||
|
guestAccess: GuestAccessLevel.WRITE,
|
||||||
useImageProxy: false,
|
useImageProxy: false,
|
||||||
specialUrls: {
|
specialUrls: {
|
||||||
privacy: 'https://example.com/privacy',
|
privacy: 'https://example.com/privacy',
|
||||||
|
|
Loading…
Reference in a new issue