+ static load () {
+ const accessTokenLocalStorage = peertubeLocalStorage.getItem(this.KEYS.ACCESS_TOKEN)
+ const refreshTokenLocalStorage = peertubeLocalStorage.getItem(this.KEYS.REFRESH_TOKEN)
+ const tokenTypeLocalStorage = peertubeLocalStorage.getItem(this.KEYS.TOKEN_TYPE)
+
+ if (accessTokenLocalStorage && refreshTokenLocalStorage && tokenTypeLocalStorage) {
+ return new Tokens({
+ accessToken: accessTokenLocalStorage,
+ refreshToken: refreshTokenLocalStorage,
+ tokenType: tokenTypeLocalStorage
+ })
+ }
+
+ return null
+ }
+
+ static flush () {
+ peertubeLocalStorage.removeItem(this.KEYS.ACCESS_TOKEN)
+ peertubeLocalStorage.removeItem(this.KEYS.REFRESH_TOKEN)
+ peertubeLocalStorage.removeItem(this.KEYS.TOKEN_TYPE)
+ }
+
+ constructor (hash?: TokenOptions) {
+ if (hash) {
+ this.accessToken = hash.accessToken
+ this.refreshToken = hash.refreshToken
+
+ if (hash.tokenType === 'bearer') {
+ this.tokenType = 'Bearer'
+ } else {
+ this.tokenType = hash.tokenType
+ }
+ }
+ }
+
+ save () {
+ peertubeLocalStorage.setItem(Tokens.KEYS.ACCESS_TOKEN, this.accessToken)
+ peertubeLocalStorage.setItem(Tokens.KEYS.REFRESH_TOKEN, this.refreshToken)
+ peertubeLocalStorage.setItem(Tokens.KEYS.TOKEN_TYPE, this.tokenType)
+ }
+}
+
+export class AuthUser extends User implements ServerMyUserModel {
+ tokens: Tokens
+ specialPlaylists: MyUserSpecialPlaylist[]
+
+ static load () {
+ const usernameLocalStorage = peertubeLocalStorage.getItem(this.KEYS.USERNAME)