Пример #1
0
 def registerUser(self, request):
     p_key = ndb.Key(UserDetails, request.phoneNumber)
     succ = 1
     user = UserDetails(
         key=p_key,
         displayName=request.displayName,
         mainEmail=request.mainEmail,
         balance=0,
         phoneNumber=request.phoneNumber,
         pin=request.pin,
         uri=request.uri,
     )
     try:
         user.put()
     except datastore_errors.DuplicatePropertyError:
         succ = 0
     prof = ProfileForm()
     if succ == 1:
         prof.displayName = user.displayName
         prof.uri = user.uri
         prof.mainEmail = user.mainEmail
         prof.balance = user.balance
         prof.phoneNumber = user.phoneNumber
     prof.success = succ
     return prof
Пример #2
0
 def googleLoginUser(self, request):
     qry = UserDetails.GoogleLogin(request.mainEmail, request.uri)
     succ = 1
     user = qry.get()
     prof = ProfileForm()
     if user is None:
         succ = 0
     elif succ == 1:
         prof.displayName = user.displayName
         prof.mainEmail = user.mainEmail
         prof.phoneNumber = user.phoneNumber
         prof.balance = user.balance
         prof.uri = user.uri
     prof.success = succ
     return prof
Пример #3
0
 def loginUser(self, request):
     p_key = ndb.Key(UserDetails, request.phoneNumber)
     user = p_key.get()
     succ = 1
     if user is None:
         succ = 0
     elif user.pin != request.pin:
         succ = 2
     prof = ProfileForm()
     if succ == 1:
         prof.displayName = user.displayName
         prof.mainEmail = user.mainEmail
         prof.phoneNumber = user.phoneNumber
         prof.balance = user.balance
         prof.uri = user.uri
     prof.success = succ
     return prof