- static load () {
- const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME)
- if (usernameLocalStorage) {
- return new AuthUser(
- {
- id: parseInt(peertubeLocalStorage.getItem(this.KEYS.ID), 10),
- username: peertubeLocalStorage.getItem(this.KEYS.USERNAME),
- email: peertubeLocalStorage.getItem(this.KEYS.EMAIL),
- role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole,
- nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType,
- webTorrentEnabled: peertubeLocalStorage.getItem(this.KEYS.WEBTORRENT_ENABLED) === 'true',
- autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true',
- videosHistoryEnabled: peertubeLocalStorage.getItem(this.KEYS.VIDEOS_HISTORY_ENABLED) === 'true'
- },
- Tokens.load()
- )
- }
-
- return null
- }
-
- static flush () {
- peertubeLocalStorage.removeItem(this.KEYS.USERNAME)
- peertubeLocalStorage.removeItem(this.KEYS.ID)
- peertubeLocalStorage.removeItem(this.KEYS.ROLE)
- peertubeLocalStorage.removeItem(this.KEYS.EMAIL)
- Tokens.flush()
- }
-
- constructor (userHash: Partial<ServerMyUserModel>, hashTokens: TokenOptions) {