Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add guest nickname handling #666

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/guest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { getBuilder } from '@nextcloud/browser-storage'
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved

const browserStorage = getBuilder('public').persist().build()

/**
* Get the guest nickname for public pages
*/
export function getGuestNickname(): string | null {
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved
return browserStorage.getItem('guestNickname')
}

/**
* Set the guest nickname for public pages
* @param nickname The nickname to set
*/
export function setGuestNickname(nickname: string): void {
browserStorage.setItem('guestNickname', nickname)
}
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export type { NextcloudUser } from './user'

export { getRequestToken, onRequestTokenUpdate } from './requesttoken'
export { getCurrentUser } from './user'
export { getGuestNickname, setGuestNickname } from './guest'
23 changes: 23 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"url": "https://github.com/nextcloud/nextcloud-auth"
},
"dependencies": {
"@nextcloud/browser-storage": "^0.4.0",
"@nextcloud/event-bus": "^3.3.1"
},
"devDependencies": {
Expand Down
Loading