1
0
-1

 I'm trying to update a User's profile with the Fluent code below. I get an exception saying 'java.lang.IllegalArgumentException: Null newPassword parameter'


import com.avoka.tm.svc.UserBuilder
import com.avoka.tm.vo.User
import com.avoka.tm.query.UserQuery
import com.avoka.core.groovy.GroovyLogger as logger
User user = new UserQuery()
.setLoginName("user@company.com")
.firstValue()
logger.info("user: ${user}")
def updatedProfile = [:]
updatedProfile.putAll(user.profileMap)
updatedProfile['language'] = 'fr'
User updatedUser = new UserBuilder("co")
.setLoginName("user@company.com")
 .setProfileMap(updatedProfile).update()
logger.info("user: ${updatedUser}")
    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Andy,

      update() is expecting the existing password for local users so it can validate it, so the error message is misleading.  If you call .setPassword() on the UserBuilder it should work.

      1. Andy Geach

        Perhaps the use of my own email address in the question was misleading, I've edited it.

        I'm trying to update a User object. I don't know the users' password, and I don't want to set a new one. I just want to change some profile values.

      2. Bill Frost

        Internally UserBuilder.update() calls updateActiveUserProfile as described by Robert, but only after it has validated the password for the account.  The Fluent API security is stopping what you are trying to do.

        You might have to consider doing it as Robert suggested, or log a change request to allow profile updates.

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Not sure of the context for this question...

      Can you use updateActiveUserProfile instead?

      Some code snips below from doing this in a Security Manager.



      // Just a few relevant lines to provide the intent... 
      
      
      import com.avoka.fc.core.dao.UserAccountDao 
      import com.avoka.fc.core.security.AccountUserDetails 
      import com.avoka.fc.core.dao.UserAccountDao 
      import com.avoka.fc.core.entity.UserAccount
      
      
      
      
      
      
      
      def userAccountDao = new UserAccountDao() 
      
      def userAccount = userAccountDao.getUserAccountForLogin(username)
      
      
      def profileMap = [:] 
      profileMap["Email"] = email 
      profileMap["Given Name"] = firstName 
      profileMap["Family Name"] = lastName 
      
      def userService = ServiceFactory.getUserService(portal) 
      
      
      if ( userAccount == null ) {  
          userAccount = userService.createSsoUserAccount(username, email, firstName, lastName, profileMap) 
      
      } 
      else { 
          // update account profile details with that from Okta  
          userService.updateActiveUserProfile(userAccount, profileMap)
        
      
          
          
          // ensure a temporary lock is cleared if needed
          userService.updateLockStatus(userAccount)
      }
      1. Andy Geach

        My question relates to use of Fluent libs; I've updated it to be more clear

      CommentAdd your comment...