apparently have to add_permission like

    user = auth.login_bare("user", "pwd")
    auth.add_permission(impersonateGroupID, "impersonate", db.auth_user,0)
    auth.impersonate(46)

    return auth.user_id

Em qui., 16 de jan. de 2020 às 15:46, António Ramos <ramstei...@gmail.com>
escreveu:

> bad english in previous email. Sorry about that.
>
> the user sysadmin belongs to group "impersonate" ike attached pic in
> previous email.
> My code to impersonate user sysadmin as user 25 returns "Forbidden"
>
> any help ?
>
> Regards
> António
>
>
> Em qui., 16 de jan. de 2020 às 15:42, António Ramos <ramstei...@gmail.com>
> escreveu:
>
>> Back again to impersonate issue. I have the sysadmin user member of
>> impersonate like the attached pic.
>> [image: image.png]
>>
>> My code to impersonate user 25 as follows "Forbidden"
>> def execdal():
>>
>>     user=auth.login_bare("sysadmin","mypwd")
>>     auth.impersonate(25)
>>
>>     return dict(a=user)
>>
>> Em qua., 18 de dez. de 2019 às 17:52, António Ramos <ramstei...@gmail.com>
>> escreveu:
>>
>>> found it
>>> Had to create a group called "impersonate"
>>> then added my user to that membership
>>> then
>>> in my function
>>>     user=auth.login_bare("teslaoneday","youwish...")
>>>
>>>     user=auth.impersonate(25)
>>> Not it works as expected...
>>>
>>> Regards
>>>
>>> Em qua., 18 de dez. de 2019 às 17:41, António Ramos <
>>> ramstei...@gmail.com> escreveu:
>>>
>>>> hello i have a controller function that is called as a get/post request
>>>> this functions then needs to log as a specific user before manipulating
>>>> data from tables.
>>>> 4 is my user id
>>>>
>>>> def checkLoad():
>>>>     user=auth.impersonate(4)
>>>>
>>>>     return "ok"
>>>>
>>>> When i call it with postman or something to test my endpoint i get
>>>>
>>>> Not Authorized
>>>>
>>>> Any ideas why ?
>>>>
>>>> Regards
>>>> António
>>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAEM0BxM1%2BjgrF4Eso_c7ntydQxasFYco-Z8hwVye9E5QgkkfFQ%40mail.gmail.com.

Reply via email to