On Sat, Jan 27, 2018 at 11:03 PM, Craig Russell <[email protected]> wrote:
> I'm confused I guess.
>
> I've seen lots of ASF::Person.find(id)
>
> Is there a way to determine if this is a real person?
By issuing an LDAP query that either will return a result (if the
person exists) or nil (if the person does not). For example:
ASF::Person.find('rubys').attrs['dn']
> Why are you suggesting ASF::Person[id]
Because it is shorter and easier to type (and read) than the example I
provided above.
> I could not find the doc for these...
>
> ?
https://whimsy.apache.org/docs/api/ASF/Person.html
https://whimsy.apache.org/docs/api/ASF/Base.html
> Craig
- Sam Ruby
>> On Jan 27, 2018, at 5:24 PM, Sam Ruby <[email protected]> wrote:
>>
>> On Sat, Jan 27, 2018 at 7:56 PM, Craig Russell <[email protected]> wrote:
>>>
>>>> On Jan 27, 2018, at 4:25 PM, Sam Ruby <[email protected]> wrote:
>>>>
>>>> ASF::Person[userName] will return nil if the person does not exist,
>>>> otherwise it will return the ASF::Person object associated with this
>>>> person.
>>>
>>> Can you see what is wrong with this code?
>>>
>>> def getMember(userId)
>>> user = ASF::Person.find(userId)
>>
>> Change above line to:
>>
>> user = ASF::Person[userId]
>>
>> [question: is the above line needed? user isn't used...]
>>
>>> mockId = params['mock']
>>> if ASF::Person.find(mockId) != nil
>>
>> Change the above line to:
>>
>> if mockId and ASF::Person[mockId]
>>
>> ASF::Person.find will always return an object that can be used to query LDAP.
>>
>>> # if mock is set, set member to mock value
>>> return mockId
>>> else
>>> return userId
>>> end
>>> end
>>>
>>> What I see is:
>>>
>>> http://whimsy.local/project/icla?token=1&mock=rubys
>>>
>>> member: rubys
>>>
>>> http://whimsy.local/project/icla?token=1
>>>
>>> member: null
>>>
>>>
>>>>
>>>> - Sam Ruby
>>>>
>>>> On Sat, Jan 27, 2018 at 7:11 PM, Craig Russell <[email protected]>
>>>> wrote:
>>>>> Hi,
>>>>>
>>>>> I'm allowing users of project/icla to pretend to be another user for the
>>>>> purpose of testing.
>>>>>
>>>>> I have this code that doesn't quite work:
>>>>>
>>>>> def getUser(userName)
>>>>> user = ASF::Person.find(userName)
>>>>> mockName = params['mock']
>>>>> if mockName != '' and ASF::Person.find(mockName).id == mockName
>>>>> # if mock is set, set member to mock value
>>>>> return mockName
>>>>> else
>>>>> return userName
>>>>> end
>>>>> end
>>>>>
>>>>> What I'm trying to do is to see if the mocked user actually exists.
>>>>>
>>>>> The code returns the mock name even if the mock name does not exist.
>>>>>
>>>>> What is the correct test for user exists?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Craig
>>>>>
>>>>> Craig L Russell
>>>>> Secretary, Apache Software Foundation
>>>>> [email protected] http://db.apache.org/jdo
>>>>>
>>>
>>> Craig L Russell
>>> Secretary, Apache Software Foundation
>>> [email protected] http://db.apache.org/jdo
>>>
>
> Craig L Russell
> Secretary, Apache Software Foundation
> [email protected] http://db.apache.org/jdo
>