3

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 (janeDoe@example.com != janedoe@example.com). 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()
garnertb
  • 9,454
  • 36
  • 38

2 Answers2

4

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.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
0

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

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • I don't know Pyton, but this seems right. Anyhow this problem is language agnostic: you always lowercase email (and usernames in general) before storing or comparing them. – Peter Knego Mar 06 '11 at 16:22