standalone: minor fixes
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 2 Oct 2023 16:07:27 +0000 (17:07 +0100)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 2 Oct 2023 16:07:57 +0000 (17:07 +0100)
ext/standaloneusers/CRM/Standaloneusers/WorkflowMessage/PasswordReset.php
ext/standaloneusers/ang/crmResetPassword.js
ext/standaloneusers/ang/crmResetPassword/crmResetPassword.html

index 3968694e39e0f1932be1f83fa9c17d7c3bd7a9a6..3797232262d427538b3434bf999c165fe42a6d83 100644 (file)
@@ -58,21 +58,19 @@ class CRM_Standaloneusers_WorkflowMessage_PasswordReset extends GenericWorkflowM
    * Generate/regenerate a token for the user and load the tplParams
    */
   public function setDataFromUser(array $user, string $token) {
-    // xxx this is not generating https://blah - just the path. Why?
     $resetUrlPlaintext = \CRM_Utils_System::url('civicrm/login/password', ['token' => $token], TRUE, NULL, FALSE);
     $resetUrlHtml = htmlspecialchars($resetUrlPlaintext);
-    $usernamePlaintext = $user['name'];
-    $usernameHtml = htmlspecialchars($user['name']);
     $this->logParams = [
-      'userID' => $user['id'],
-      'username' => $usernamePlaintext,
-      'email' => $user['uf_name'],
+      'userID'   => $user['id'],
+      'username' => $user['username'],
+      'email'    => $user['uf_name'],
+      'url'      => $resetUrlPlaintext,
     ];
     $this
       ->setResetUrlPlaintext($resetUrlPlaintext)
       ->setResetUrlHtml($resetUrlHtml)
-      ->setUsernamePlaintext($usernamePlaintext)
-      ->setUsernameHtml($usernameHtml)
+      ->setUsernamePlaintext($user['username'])
+      ->setUsernameHtml(htmlspecialchars($user['username']))
       ->setTo($user['uf_name']);
     return $this;
   }
index d86a6b1902f46d48acbbfa07d1eba2610fc387df..a32b93213fbf54a1665d64ba5a331ca19f0a308b 100644 (file)
       var ts = $scope.ts = CRM.ts(null),
       ctrl = this;
 
-      console.log('init crmResetPassword component starting');
+      // console.log('init crmResetPassword component starting');
       // $onInit gets run after the this controller is called, and after the bindings have been applied.
       // this.$onInit = function() { console.log('user', ctrl.userId); };
-      ctrl.formSubmitted = false;
-      ctrl.newPassword = '';
-      ctrl.newPasswordAgain = '';
-      ctrl.identifier = '';
-      ctrl.busy = '';
-      ctrl.pwnd = false;
-      ctrl.resetSuccessfullySubmitted = false;
+
+      ctrl.completeReset = () => {
+        ctrl.busy='';
+        ctrl.formSubmitted = false;
+        ctrl.identifier = '';
+        ctrl.newPassword = '';
+        ctrl.newPasswordAgain = '';
+        ctrl.pwnd = false;
+        ctrl.resetSuccessfullySubmitted=false;
+        ctrl.token='';
+      };
+      ctrl.completeReset();
 
       let updateAngular = (prop, newVal) => {
         $timeout(() => {
index f81f3c3949259b2d86f812c23622c0d16a857d41..26793c848eca86040d5117a6e0dc57435a4fa8cc 100644 (file)
@@ -54,7 +54,7 @@
 
   <div ng-if="$ctrl.token === 'invalid'" >
     <p>{{ts("This password reset link has expired or is otherwise invalid.")}}</p>
-    <p><a href ng-click="$ctrl.token=''" >{{ts('Send new password reset link')}}</a></p>
+    <p><a href ng-click="$ctrl.completeReset()">{{ts('Send new password reset link')}}</a></p>
   </div>
 
 </div>