@annalib/anna-cognito-lib 2.2.6 → 2.2.8

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.
@@ -114,8 +114,8 @@ class AnnaLibAuthService {
114
114
  }
115
115
  ngOnInit() { }
116
116
  async isUserLoggedIn() {
117
- let currentUser = await getCurrentUser();
118
- if (currentUser) {
117
+ try {
118
+ await getCurrentUser();
119
119
  return new Promise(async (resolve, reject) => {
120
120
  const session = await fetchAuthSession();
121
121
  if (session?.tokens) {
@@ -130,7 +130,7 @@ class AnnaLibAuthService {
130
130
  }
131
131
  });
132
132
  }
133
- else {
133
+ catch (error) {
134
134
  return new Promise((resolve) => {
135
135
  clearInterval(this.accessTokenTimerId);
136
136
  resolve(false);
@@ -155,6 +155,7 @@ class AnnaLibAuthService {
155
155
  case "DONE":
156
156
  let session = await fetchAuthSession();
157
157
  let newExpTime = this.computeTokenExpiration(session.tokens.idToken);
158
+ this.accessToken = session.tokens.accessToken.toString();
158
159
  localStorage.setItem("accessTokenExpiration", newExpTime.toString());
159
160
  this.refreshAccessToken();
160
161
  this.loginErrorMessage = null;