garnertb
garnertb

Reputation: 9584

Google App Engine using UserProperty to link data

I am writing an application in GAE. In order to link the currently logged in user to data in my application I have been relying on equality between users.get_current_user() and members.user (see model below). Where I run into trouble is when the user signs in with an email address using different capitalization than his/her initial login ([email protected] != [email protected]). What is the most reliable way to link the current user to application specific data?

class members(db.Model):
    firstName=db.StringProperty(verbose_name='First Name',required=True)
    lastName=db.StringProperty(verbose_name='Last Name',required=True)
    user=db.UserProperty()

Upvotes: 3

Views: 544

Answers (2)

Nick Johnson
Nick Johnson

Reputation: 101149

Don't use the username - call user.user_id(), and compare on that. It's guaranteed to remain the same, even if nickname or email address change.

Upvotes: 4

Peter Knego
Peter Knego

Reputation: 80340

Always convert username to lowercase and then do operations on it: when storing the first time and on later comparisons.

Upvotes: 0

Related Questions