@solidev/data 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1688,12 +1688,10 @@ let AuthServiceBase = class AuthServiceBase {
|
|
|
1688
1688
|
}
|
|
1689
1689
|
get currentUser$() {
|
|
1690
1690
|
// Needs refresh ?
|
|
1691
|
-
if (this.isAnonymous
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
Date.now() - this._fetched >
|
|
1696
|
-
(this._params.userFetchValiditySeconds || 3600) * 1000) {
|
|
1691
|
+
if (!this.isAnonymous &&
|
|
1692
|
+
(!this._fetched ||
|
|
1693
|
+
Date.now() - this._fetched >
|
|
1694
|
+
(this._params.userFetchValiditySeconds || 3600) * 1000)) {
|
|
1697
1695
|
this._fetched = Date.now();
|
|
1698
1696
|
return this._fetchUser().pipe(switchMap(() => {
|
|
1699
1697
|
return this._user$.asObservable();
|
|
@@ -1743,10 +1741,9 @@ let AuthServiceBase = class AuthServiceBase {
|
|
|
1743
1741
|
payload[this._params.passwordField] = password;
|
|
1744
1742
|
return this._http.post(this.loginUrl, payload).pipe(tap((tok) => {
|
|
1745
1743
|
this._token = new Jwt(tok);
|
|
1746
|
-
this.saveAuth();
|
|
1747
1744
|
}), switchMap(() => {
|
|
1748
1745
|
return this._fetchUser();
|
|
1749
|
-
}), map(() => 'success'), catchError((error) => {
|
|
1746
|
+
}), map(() => 'success'), tap(() => this.saveAuth()), catchError((error) => {
|
|
1750
1747
|
this.logout();
|
|
1751
1748
|
const code = error.error?.code || error?.code || 'error';
|
|
1752
1749
|
console.error(code, error);
|
|
@@ -1758,8 +1755,7 @@ let AuthServiceBase = class AuthServiceBase {
|
|
|
1758
1755
|
access: accessToken,
|
|
1759
1756
|
refresh: refreshToken,
|
|
1760
1757
|
});
|
|
1761
|
-
this.saveAuth()
|
|
1762
|
-
return this._fetchUser().pipe(map(() => 'success'), catchError((error) => {
|
|
1758
|
+
return this._fetchUser().pipe(map(() => 'success'), tap(() => this.saveAuth()), catchError((error) => {
|
|
1763
1759
|
this.logout();
|
|
1764
1760
|
const code = error.error?.code || error?.code || 'error';
|
|
1765
1761
|
console.error(code, error);
|