Project Member
Reported by
molhokwai,
Jun 22, 2010
What steps will reproduce the problem?
1. Download source from github
2. Implement source in web2py (create app, and copy paste)
3. Click on the login button
What is the expected output? What do you see instead?
Logical 'user not existing' message, but no way to register (unless I missed something)
What version of the product are you using? On what operating system?
Source of today (2010-06-22) from github
Please provide any additional information below.
Implemented Fix. See code below. Also see attached .w2p app file.
Recommendations:
As Google app engine has OAuth implemented, I think the wisest thing to do is to:
- keep the classical login registration available
- and implement GAE OAuth
The registration link/page would go something like: "Create a login Or Register with one of your existing account provider..."
VoilĂ .
Thanks.
CODE:
<code class="python" lang="en">
###################################################
Controllers/default.py: Line 0
###################################################
# This sets the session authorization values
if request.env.web2py_runtime_gae:
from google.appengine.api import users
user=users.get_current_user()
if user:
response.user=user
response.logout_url=users.create_logout_url(request.env.path_info)
session.user_id=user.user_id()
session.email=user.email()
session.alias=user.nickname()
session.flash='User logged in'
else:
response.user=None
session.user_id=None
session.email=None
session.alias=None
response.login_url=users.create_login_url(request.env.path_info)
session.authorized=users.is_current_user_admin()
else:
from gluon.fileutils import check_credentials
session.authorized=check_credentials(request)
</code>
###################################################
views/layout.html : Mini Admin & Meta
###################################################
<code class="html" lang="en">
{{if session.authorized:}}
<li>
<h2>Mini Admin</h2>
<ul>
<li><a href="{{=URL(r=request,f='add/page')}}">Add Page</a></li>
<li><a href="{{=URL(r=request,f='add/post')}}">Add Post</a></li>
<li><a href="{{=URL(r=request,f='edit/bloginfo')}}">Edit Blog Info</a></li>
<li><a href="{{=URL(r=request,f='edit/userinfo')}}">Edit User Info</a></li>
{{ if request.env.web2py_runtime_gae: }}
{{if response.user:}}
<li><a href="{{=response.logout_url}}">Log out</a></li>
{{pass}}
{{else:}}
<li><a href="{{=URL(r=request,f='logout')}}">Log Out</a></li>
{{pass}}
</ul>
</li>
{{else:}}
<li>
<h2>Meta</h2>
{{ if request.env.web2py_runtime_gae: }}
{{if response.user:}}
<!-- this case is never reached -->
{{else:}}
<ul>
<li><a href="{{=response.login_url}}">Log In</a></li>
</ul>
{{pass}}
{{ else: }}
<ul>
<li><a href="{{=URL(r=request,f='login')}}">Log In</a></li>
</ul>
{{pass}}
</li>
{{pass}}
</code>
|
web2py.app.pypress4gae.w2p
41.8 KB
Download
|