9 Replies Latest reply on Feb 9, 2016 8:24 AM by pchung RSS
    kqian Explorer

    Logout & Change Password

    How can I realize the function(Logout & Change Password) in a mashup like the  screenshot as follows:

    捕获.PNG

      • Re: Logout & Change Password
        carlesc Ninja

        For the Logout, you need to download the Logout Button Widget: ThingWorx IoT Marketplace » Logout Button

         

        For the Change Password, I think you can do it from Server Side Javascript with this code ( I've never tested it ):

         

         

        var params = {

          newPasswordConfirm: undefined /* STRING */,

          oldPassword: undefined /* STRING */,

          newPassword: undefined /* STRING */

        };

         

        Users[user_name].ChangePassword(params);

         

        For instance for user_name you can use: Resources["CurrentSessionInfo"].GetCurrentUser()

        • Re: Logout & Change Password
          paic Collaborator

          Something else that is helpful, there is also AssignNewPassword

           

           

          var params = {

            newPasswordConfirm: undefined /* STRING */,

            newPassword: undefined /* STRING */

          };

           

           

          // no return

          Users["UserName"].AssignNewPassword(params);

            • Re: Logout & Change Password
              anna Creator

              Hi Pai,

              Have you tested against service AssignNewPassword? I got error when test this service:

              Wrapped java.lang.Exception: Invalid New Password Specified Cause: Invalid New Password Specified


              This is my code:

              var params = {

                  newPasswordConfirm: "abc" /* STRING */,

                  newPassword: "abc" /* STRING */

               

              };

              // no return

              Users["MyUserName"].AssignNewPassword(params);

              • Re: Logout & Change Password
                anna Creator

                Issue is fixed. The root cause is that there is a minimum length for new password length which is 5.

                So issue is fixed after setting newPassword nad newPasswordConfirm as "admin".

                But we didnt find any instruction for this limitation till now.

                 

                Thanks,

                 

                Br,

                Anna

                • Re: Logout & Change Password
                  lpthingworx Explorer

                  Hi Pai,

                  In our application, specific user can set new password for users. but  AssignNewPassword(params) is only working with Administrator user.

                  we can use ChangePassword(params) but it requires a old password of user, so can we get existing password of user using any service?

                    • Re: Logout & Change Password
                      pchung Collaborator

                      It will also work with SecurityAdministrators so you can set up users to have that permission.

                      Please note that whoever you give this permission to, can execute it not only in your mashup, but also through the REST API, so you have to make sure you think through how you give access to this functionality.

                       

                      In 6.6 the FormLogin page of the Organization also has a Password reset capability.

                        • Re: Logout & Change Password
                          lpthingworx Explorer

                          Thanks Pai,

                          But i am afraid that securityAdministrators will not work with our application architecture. that user is only allowed to assign new password and restrict to other screens. Can we achieve this with any other way?

                            • Re: Logout & Change Password
                              pchung Collaborator

                              In principle the AssignPassword is an Administrative function.

                              So if you have architectural limitations to have Administrative functions, then you probably have a rather complicated landscape that may go beyond just a simple community answer.

                              As a suggestion, perhaps you can approach PTC Global Services and get architect services from PTC GS.