Skip to content

Commit

Permalink
Merge pull request #666 from nextcloud-libraries/feat/shared-nick
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Jul 18, 2024
2 parents 0edbb4f + a43ebbf commit 331c56e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
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'

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

/**
* Get the guest nickname for public pages
*/
export function getGuestNickname(): string | null {
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

0 comments on commit 331c56e

Please sign in to comment.