parameters: (analyst, data)
docstring: Update a user profile.
  
      :param analyst: The user to update.
      :type analyst: str
      :param data: The user profile fields to change and their values.
      :type data: dict
      :returns: dict with keys "success" (boolean) and "message" (str) if failed.
docstring_summary: Update a user profile.
docstring_tokens: Update a user profile .
function: def modify_source_access(analyst, data):
      """
      Update a user profile.
  
      :param analyst: The user to update.
      :type analyst: str
      :param data: The user profile fields to change and their values.
      :type data: dict
      :returns: dict with keys "success" (boolean) and "message" (str) if failed.
      """
  
      user = CRITsUser.objects(username=data['username']).first()
      if not user:
          user = CRITsUser.create_user(
              data.get('username', ''),
              data.get('password', ''),
              data.get('email') )
          if not user:
              return {'success': False,
                      'message': 'Missing user information username/password/email'}
      user.first_name = data['first_name']
      user.last_name = data['last_name']
      user.email = data['email']
      user.roles = data['roles']
      user.organization = data['organization']
      user.totp = data['totp']
      user.secret = data['secret']
      if len(data.get('password', '')) > 1:
          if user.set_password(data['password']) == False:
              config = CRITsConfig.objects().first()
              pc = config.password_complexity_desc
              return {'success': False,
                      'message': 'Password does not meet complexity policy: %s' % pc}
      if data['subscriptions'] == '':
          user.subscriptions = EmbeddedSubscriptions()
      user.acl_needs_update = True
      try:
          user.save(username=analyst)
          return {'success': True}
      except ValidationError, e:
          return {'success': False,
                  'message': format_error(e)}
function_tokens: def modify_source_access ( analyst , data ) : user = CRITsUser . objects ( username = data [ 'username' ] ) . first ( ) if not user : user = CRITsUser . create_user ( data . get ( 'username' , '' ) , data . get ( 'password' , '' ) , data . get ( 'email' ) ) if not user : return { 'success' : False , 'message' : 'Missing user information username/password/email' } user . first_name = data [ 'first_name' ] user . last_name = data [ 'last_name' ] user . email = data [ 'email' ] user . roles = data [ 'roles' ] user . organization = data [ 'organization' ] user . totp = data [ 'totp' ] user . secret = data [ 'secret' ] if len ( data . get ( 'password' , '' ) ) > 1 : if user . set_password ( data [ 'password' ] ) == False : config = CRITsConfig . objects ( ) . first ( ) pc = config . password_complexity_desc return { 'success' : False , 'message' : 'Password does not meet complexity policy: %s' % pc } if data [ 'subscriptions' ] == '' : user . subscriptions = EmbeddedSubscriptions ( ) user . acl_needs_update = True try : user . save ( username = analyst ) return { 'success' : True } except ValidationError , e : return { 'success' : False , 'message' : format_error ( e ) }