Skip to content

Commit f233a12

Browse files
committed
[#323] fixed and deprecated isAdmin/isAuthRecord store getters
1 parent 7289704 commit f233a12

21 files changed

+141
-40
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.22.1
2+
3+
- Fixed old `pb.authStore.isAdmin`/`pb.authStore..isAuthRecord` and marked them as depricated in favour of `pb.authStore.isSuperuser` ([#323](https://github.com/pocketbase/js-sdk/issues/323)).
4+
_Note that with PocketBase v0.23.0 superusers are converted to a system auth collection so you can always simply check the value of `pb.authStore.record?.collectionName`._
5+
6+
17
## 0.22.0
28

39
**⚠️ This release introduces some breaking changes and works only with PocketBase v0.23.0+.**

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,10 @@ BaseAuthStore {
238238
record: RecordModel|null // the authenticated auth record
239239
token: string // the authenticated token
240240
isValid: boolean // checks if the store has existing and unexpired token
241-
isAdmin: boolean // checks if the store state is for admin
242-
isAuthRecord: boolean // checks if the store state is for an auth record
241+
isSuperuser: boolean // checks if the store state is for superuser
243242
244243
// main methods
245-
clear() // "logout" the authenticated record or admin model
244+
clear() // "logout" the authenticated record
246245
save(token, record) // update the store with the new auth data
247246
onChange(callback, fireImmediately = false) // register a callback that will be called on store change
248247
@@ -252,7 +251,7 @@ BaseAuthStore {
252251
}
253252
```
254253

255-
To _"logout"_ an authenticated record or admin you can call `pb.authStore.clear()`.
254+
To _"logout"_ the authenticated record you can call `pb.authStore.clear()`.
256255

257256
To _"listen"_ for changes in the auth store, you can register a new listener via `pb.authStore.onChange`, eg:
258257
```js

dist/pocketbase.cjs.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,17 @@ declare class BaseAuthStore {
159159
*/
160160
get isValid(): boolean;
161161
/**
162-
* Checks whether the current store state is for admin authentication.
162+
* Loosely checks whether the currently loaded store state is for superuser.
163+
*
164+
* Alternatively you can also compare directly `pb.authStore.record?.collectionName`.
165+
*/
166+
get isSuperuser(): boolean;
167+
/**
168+
* @deprecated use `isSuperuser` instead or simply check the record.collectionName property.
163169
*/
164170
get isAdmin(): boolean;
165171
/**
166-
* Checks whether the current store state is for auth record authentication.
172+
* @deprecated use `!isSuperuser` instead or simply check the record.collectionName property.
167173
*/
168174
get isAuthRecord(): boolean;
169175
/**
@@ -1005,7 +1011,7 @@ declare class FileService extends BaseService {
10051011
[key: string]: any;
10061012
}, filename: string, queryParams?: FileOptions): string;
10071013
/**
1008-
* Requests a new private file access token for the current auth model (admin or record).
1014+
* Requests a new private file access token for the current auth model.
10091015
*
10101016
* @throws {ClientResponseError}
10111017
*/

dist/pocketbase.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.d.mts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,17 @@ declare class BaseAuthStore {
181181
*/
182182
get isValid(): boolean;
183183
/**
184-
* Checks whether the current store state is for admin authentication.
184+
* Loosely checks whether the currently loaded store state is for superuser.
185+
*
186+
* Alternatively you can also compare directly `pb.authStore.record?.collectionName`.
187+
*/
188+
get isSuperuser(): boolean;
189+
/**
190+
* @deprecated use `isSuperuser` instead or simply check the record.collectionName property.
185191
*/
186192
get isAdmin(): boolean;
187193
/**
188-
* Checks whether the current store state is for auth record authentication.
194+
* @deprecated use `!isSuperuser` instead or simply check the record.collectionName property.
189195
*/
190196
get isAuthRecord(): boolean;
191197
/**
@@ -1048,7 +1054,7 @@ declare class FileService extends BaseService {
10481054
[key: string]: any;
10491055
}, filename: string, queryParams?: FileOptions): string;
10501056
/**
1051-
* Requests a new private file access token for the current auth model (admin or record).
1057+
* Requests a new private file access token for the current auth model.
10521058
*
10531059
* @throws {ClientResponseError}
10541060
*/

dist/pocketbase.es.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,17 @@ declare class BaseAuthStore {
181181
*/
182182
get isValid(): boolean;
183183
/**
184-
* Checks whether the current store state is for admin authentication.
184+
* Loosely checks whether the currently loaded store state is for superuser.
185+
*
186+
* Alternatively you can also compare directly `pb.authStore.record?.collectionName`.
187+
*/
188+
get isSuperuser(): boolean;
189+
/**
190+
* @deprecated use `isSuperuser` instead or simply check the record.collectionName property.
185191
*/
186192
get isAdmin(): boolean;
187193
/**
188-
* Checks whether the current store state is for auth record authentication.
194+
* @deprecated use `!isSuperuser` instead or simply check the record.collectionName property.
189195
*/
190196
get isAuthRecord(): boolean;
191197
/**
@@ -1048,7 +1054,7 @@ declare class FileService extends BaseService {
10481054
[key: string]: any;
10491055
}, filename: string, queryParams?: FileOptions): string;
10501056
/**
1051-
* Requests a new private file access token for the current auth model (admin or record).
1057+
* Requests a new private file access token for the current auth model.
10521058
*
10531059
* @throws {ClientResponseError}
10541060
*/

dist/pocketbase.es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/pocketbase.es.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)