Skip to content

Commit

Permalink
feat: add guest nickname handling
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jul 18, 2024
1 parent 0edbb4f commit 137af0e
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 shares
*/
export function getGuestNickname(): string | null {
return browserStorage.getItem('guestNickname')
}

/**
* Set the guest nickname for public shares
* @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 137af0e

Please sign in to comment.