Browse Source

Handle `connection._sasl_mechanism` not being defined

Fixes #3719
Fixes #3770
JC Brand 1 month ago
parent
commit
301995a335
1 changed files with 5 additions and 8 deletions
  1. 5 8
      src/plugins/profile/utils.js

+ 5 - 8
src/plugins/profile/utils.js

@@ -1,5 +1,5 @@
 import { __ } from 'i18n';
-import { _converse } from '@converse/headless';
+import { _converse, api } from '@converse/headless';
 
 /**
  * @param {string} stat
@@ -27,14 +27,11 @@ export function getPrettyStatus(stat) {
 export function shouldShowPasswordResetForm() {
     const conn = _converse.api.connection.get();
     const mechanism = conn._sasl_mechanism;
-    if (
-        mechanism.mechname === 'EXTERNAL' ||
-        mechanism.mechname === 'ANONYMOUS' ||
-        mechanism.mechname === 'X-OAUTH2' ||
-        mechanism.mechname === 'OAUTHBEARER'
-    ) {
+    if (mechanism && ['EXTERNAL', 'ANONYMOUS', 'X-OAUTH2', 'OAUTHBEARER'].includes[mechanism.mechname]) {
+        return false;
+    } else if (['external', 'anonymous'].includes(api.settings.get('authentication'))) {
         return false;
     }
+
     return true;
 }
-