Lines Matching defs:User
29 For example, suppose we have a model `User` with three properties that
32 class User(model.Model):
37 To ensure property uniqueness when creating a new `User`, we first create
39 save the new `User` record::
45 'User.username.%s' % username,
46 'User.auth_id.%s' % auth_id,
47 'User.email.%s' % email,
54 # The unique values were created, so we can save the user.
55 user = User(username=username, auth_id=auth_id, email=email)
56 user.put()
57 return user
77 For example, for a unique property `email` from kind `User`, the
78 value can be `User.email:me@myself.com`. In this case `User.email`
133 user = model.StringProperty(required=True, indexed=False)
138 def get_key(cls, user, subject, token):
141 :param user:
142 User unique ID.
154 return model.Key(cls, '%s.%s.%s' % (str(user), subject, token))
157 def create(cls, user, subject, token=None):
158 """Creates a new token for the given user.
160 :param user:
161 User unique ID.
173 user = str(user)
175 key = cls.get_key(user, subject, token)
176 entity = cls(key=key, user=user, subject=subject, token=token)
181 def get(cls, user=None, subject=None, token=None):
182 """Fetches a user token.
184 :param user:
185 User unique ID.
196 if user and subject and token:
197 return cls.get_key(user, subject, token).get()
204 class User(model.Expando):
205 """Stores user authentication credentials or authorization ids."""
221 """Returns this user's unique ID, which can be an integer or string."""
225 """A helper method to add additional auth ids to a User
228 String representing a unique id for the user. Examples:
233 A tuple (boolean, info). The boolean indicates if the user
234 was saved. If creation succeeds, ``info`` is the user entity;
249 """Returns a user object based on a auth_id.
252 String representing a unique id for the user. Examples:
257 A user object.
263 """Returns a user object based on a user ID and token.
266 The user_id of the requesting user.
270 A tuple ``(User, timestamp)``, with a user object and
276 valid_token, user = model.get_multi([token_key, user_key])
277 if valid_token and user:
279 return user, timestamp
285 """Returns a user object, validating password.
292 A user object, if found and password matches.
296 user = cls.get_by_auth_id(auth_id)
297 if not user:
300 if not security.check_password_hash(password, user.password):
303 return user
310 User unique ID.
321 return cls.token_model.get(user=user_id, subject=subject,
326 """Creates a new authorization token for a given user ID.
329 User unique ID.
344 User unique ID.
365 """Creates a new user.
368 A string that is unique to the user. Users may have multiple
380 Keyword arguments to create a new user entity. Since the model is
384 A tuple (boolean, info). The boolean indicates if the user
385 was created. If creation succeeds, ``info`` is the user entity;
393 'Creating a user with multiple auth_ids is not allowed, ' \
401 user = cls(**user_values)
412 user.put()
413 return True, user