Comments (4)
That is another case of documentation being missed.
The way it works is:
auth_id -----> extended profile
|----> local auth
|----> openID provider.
the extended profile is a parallel table to the authentication table, and the user table actually allows multiple authentication methods to be associated with a single authentication id. This way, a user on your system could have a local auth and attach a Facebook auth to it. They would have two different ways to log into the same Auth ID.
I've cleaned up the docs slightly, but, need to document things a little better as that was written before the main rewrite of Apex.
from apex.
so right now if I want to add the first name and last name fields I can do something like this?
in models/init.py
from apex.models import AuthID
class ForeignKeyProfile(Base):
tablename = 'auth_user_profile'
id = Column(types.BigInteger, primary_key=True)
auth_id = Column(types.BigInteger, ForeignKey(AuthID.id), index=True)
""" Add your locally defined options here
"""
first_name = Column(Unicode(80))
last_name = Column(Unicode(80))
user = relationship(AuthID, backref=backref('profile', uselist=False))
def __int__(self,auth_id, first_name, last_name);
self.auth_id = auth_id
self.first_name = first_name
self.last_name = last_name
in project/models/profile.py
from apex.forms import RegisterForm
from project.models import DBSession
from project.models import ForeignKeyProfile
class NewRegisterForm(RegisterForm):
first_name = TextField(u'First Name', [validators.length(max=10)])
last_name = TextField(u'Last Name', [validators.length(max=10)])
def after_signup(self, user):
profile = ForeignKeyProfile(auth_id=user.auth_id,first_name=self.data['first_name'], last_name=self.data['last_name']) # is this correct???????
DBSession.add(profile)
DBSession.flush()
by the way ,under the "If you are using OpenID providers: section". why there is
project/profile.py and project/models/profile.py ? there should be only one file, right?
and class openid_after(object): should be class openid_after(RegisterForm): , right ???
also what is the usage of the ExtendedProfile class in apex_example/models.py ?
Thank you ! sorry to ask you so many questions. I'm a newbie
from apex.
shouldn't be AuthID = relationship(AuthID, backref=backref('profile', uselist=False)) rather than
user = relationship(AuthID, backref=backref('profile', uselist=False)) ? Thank you!
from apex.
I need to remove one of those sections. The early version of Apex made the distinction between a locally created user and an OpenID created user. The one on the top of that page is the most accurate.
project/profile.py and project/models/profile.py is a typo, it should be in models.
openid_after(object): should be class openid_after(RegisterForm):
You're sending an object through, not the form. However, the documentation is again out of date here. Here's a sample from some code using the current version of Apex.
class openid_after:
def after_signup(self, **kwargs):
request = kwargs.pop('request', False)
if kwargs.has_key('user'):
user = kwargs.pop('user', False)
profile = get_or_create(DBSession, User_Profile, auth_id=user.id)
DBSession.flush()
return request
user = relationship(AuthID, backref=backref('profile', uselist=False))
You are correct, overactive search and replace when fixing the docs.
Leaving this open until I get a chance to fix the docs and update the example
from apex.
Related Issues (20)
- Is this project still maintained? HOT 1
- Tried to run the apex example and ran into the following problem HOT 3
- The "locale" folder is missing in egg HOT 2
- Why not re-use pyramid.security.Authenticated HOT 3
- Quickstart form action is not correct HOT 4
- "HTTPForbidden: CSRF token is missing or invalid" after successful facebook authentication HOT 1
- NameError: global name 'auth' is not defined HOT 3
- Example is broken on import HOT 2
- Quickstart velruse not working HOT 2
- Ajax 302 Found Redirect Bug HOT 4
- Confusion with RegisterForm and after_signup
- multiple accounts HOT 4
- Ignores 'profile details' coming from twitter(or any other provider) after login
- Quickstart example fails on Mavericks 10.9.2, Python 2.7.5 HOT 4
- Quickstart documentation out of date HOT 2
- Naming convention problem on SQL Server
- Microsoft Live Error: ThirdPartyFailure: The HTTP request was forbidden with client authentication scheme 'Anonymous'. HOT 1
- Valruse vs Apex callbacks HOT 1
- Python 3.5.1: TypeError: Class advice impossible in Python3. Use the @implementer class decorator instead HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex.