Example #1
0
 def login(cls, name, pw):
   """Returns the entity instance if the provided username and password match"""
   u = User.getName(name)
   return u if u and u.pw == utils.genPwHash(name, pw, u.pw.split('|')[0]) else None
Example #2
0
 def register(cls, name, pw, email=None):
   """Returns a new entity instance for the given attributes"""
   pw = utils.genPwHash(name, pw)
   return cls(parent=User.getKey(), name=name, pw=pw, email=email)