@stokr/components-library 3.0.43 → 3.0.44

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.
@@ -134,6 +134,15 @@ class Auth {
134
134
  });
135
135
  });
136
136
  }
137
+ static reportFailedLoginAttempt(email) {
138
+ return new Promise((resolve, reject) => {
139
+ axiosInstance.post(`auth/failed-login-attempt`, { email }).then((response) => {
140
+ resolve(response.data);
141
+ }).catch((err) => {
142
+ reject(err);
143
+ });
144
+ });
145
+ }
137
146
  static resendActivationEmail(email) {
138
147
  return new Promise((resolve, reject) => {
139
148
  axiosInstance.post(`auth/resend-activation-email`, {
@@ -124,11 +124,13 @@ class AuthProviderClass extends Component {
124
124
  if (!expiresAt) return;
125
125
  const delay = expiresAt - Date.now();
126
126
  if (delay <= 0) {
127
+ Auth.logout();
127
128
  this.setState({ sessionExpiryPendingReason: "cookie" });
128
129
  return;
129
130
  }
130
131
  this.cookieExpiryTimerRef = setTimeout(() => {
131
132
  this.cookieExpiryTimerRef = null;
133
+ Auth.logout();
132
134
  this.setState({ sessionExpiryPendingReason: "cookie" });
133
135
  }, delay);
134
136
  };
@@ -176,6 +178,7 @@ class AuthProviderClass extends Component {
176
178
  const delay = this.getInactivityTimeMs();
177
179
  this.inactivityTimerRef = setTimeout(() => {
178
180
  this.inactivityTimerRef = null;
181
+ Auth.logout();
179
182
  this.setState({ sessionExpiryPendingReason: "inactivity" });
180
183
  }, delay);
181
184
  }
@@ -222,8 +225,18 @@ class AuthProviderClass extends Component {
222
225
  break;
223
226
  case "auth/invalid-login-credentials":
224
227
  case "auth/invalid-credential":
228
+ if (email) {
229
+ Auth.reportFailedLoginAttempt(email).catch(() => {
230
+ });
231
+ }
225
232
  error.message = "The credentials are not correct. Try again?";
226
233
  throw error;
234
+ case "auth/user-disabled":
235
+ error.message = "Your account has been locked due to too many failed login attempts. Please contact support at support.stokr.io to reactivate.";
236
+ throw error;
237
+ case "auth/too-many-requests":
238
+ error.message = "Too many sign-in attempts. Please wait a few minutes before trying again.";
239
+ throw error;
227
240
  case "auth/invalid-custom-token":
228
241
  case "auth/argument-error":
229
242
  error.message = "This sign-in link is invalid, expired, or was already used. Please sign in again or request a new link.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "3.0.43",
3
+ "version": "3.0.44",
4
4
  "description": "STOKR - Components Library",
5
5
  "author": "Bilal Hodzic <bilal@stokr.io>",
6
6
  "license": "MIT",