Hi

I have tried your suggestion and put the code
auth.settings.login_url = URL(c='default', f='fbLogin', args=['login'])

this is in my default.py
def fbLogin():
auth.settings.login_form=FaceBookAccount()
auth.settings.login_url = URL(c='default', f='fbLogin', args=['login'])
form = auth()

return dict(form=form)

No matter I put in db.py or my controller,
when user login will see like the picture

<http://i.imgur.com/xTgJop4.png>

the url is
https://www.facebook.com/dialog/oauth
?state=auth_provider%3Dfacebook
*&redirect_uri=https%3A%2F%2Fmydomain%2F[app]%2Fdefault%2Fuser%2Flogin*
&response_type=code
&client_id=MY_CLIENT_ID
&scope=public_profile%2C+email
&display=popup

the *redirect_uri* is what I want to change. as above code. *redirect_uri = 
https://mydomain/[app]/default/user/login*. 
And I want it change to  *https://mydomain/[app]/default/fbLogin*.

mcm於 2016年4月11日星期一 UTC+8下午4時55分58秒寫道:
>
> In the standard web2py authentication is triggered by @auth.requires_login 
> decorator if the user is not authenticated already.
>
> in model after defining a class FacebookAccount() extended from 
> gluon.contrib.oauth20_account.OAuthAccount
>
>
> auth.settings.login_form = FacebookAccount()
>
> # change default login action
> # default is auth.settings.login_url = URL('user', args='login')
> auth.settings.login_url = URL(c='mycontroller', f='my_login_action', 
> args=['login'])
>
> in mycontroller.py:
>
> def my_login_action():
>   """same as default/login action"""
>   return dict(form=auth())
>
>
> @auth.requires_login():
> def f():
>   ...
>
>
> 2016-04-11 7:21 GMT+02:00 killzane <kill...@gmail.com <javascript:>>:
>
>> I see all settings but I don't know what attribute I should change.
>> the *redirect_uri* args I mean is when log with facebook will goto 
>>
>> https://www.facebook.com/dialog/oauth?
>> client_id=568390199919780&
>> scope=email,user_birthday&
>> *redirect_uri*=https://my_domain/[app]/default/user/login
>>
>> because if the rediect_uri don't have the *FaceBookAccount()* instance 
>> it will show error and can't login success.
>>
>> So I just use a "_blank" link to open my *fbLogin *page?
>>
>> mcm於 2016年4月11日星期一 UTC+8上午3時48分18秒寫道:
>>>
>>> You should be able to change redirect url using the standard settings of 
>>> auth.
>>>
>>>
>>> http://www.web2py.com/books/default/chapter/29/09/access-control#Auth-Settings-and-messages
>>>
>>> You do not need ajax, just a window.open() or a <a href=".." 
>>> target="_blank"> or an iframe
>>>
>>>
>>>
>>> 2016-04-10 9:38 GMT+02:00 killzane <kill...@gmail.com>:
>>>
>>>> I followed the web2py book 
>>>> http://web2py.com/books/default/chapter/29/09/access-control#Other-login-methods-and-login-forms
>>>>  and 
>>>> put the example code in my model
>>>>
>>>> and I use this in my controllers named *default.py*
>>>> def fbLogin():
>>>> auth.settings.login_form=FaceBookAccount()
>>>> form = auth()
>>>>
>>>> return dict(form=form)
>>>>
>>>> When I visit this page, I can see facebook Oauth.
>>>> there are some problem I want to solve.
>>>> 1. why the *redirect_uri* set to [app]/default/user/login but not 
>>>> [app]/default/fbLogin?
>>>> may I set it manual?
>>>>
>>>> 2. facebook suggest me to show a window to show the Oauth page, but I'm 
>>>> not really know how to do it in web2py.
>>>> I should use ajax to do it? or some other way?
>>>>
>>>> -- 
>>>> 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+un...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> -- 
>> 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+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to