def delete_user(email_id):
     user_obj = Users.get_by_id(email_id)
     if user_obj:
         ndb.Key(Users, email_id).delete()
         return {"status": "success", "msg": " deleted"}
     else:
         return {"status": "error", "msg": "invalid credentials"}
 def update_user(email_id, fav_food):
     user_obj = Users.get_by_id(email_id)
     if user_obj:
         Users.create_or_update(user_obj.name, email_id, fav_food,
                                user_obj.platform)
         return {"status": "success", "msg": " updated"}
     else:
         return {"status": "error", "msg": "invalid credentials"}
 def register_a_user(name, email_id, fav_food, platform):
     log.info(name)
     user_obj = Users.get_by_id(email_id)
     if not user_obj:
         Users.create_or_update(name, email_id, fav_food, platform)
         return {"status": "success", "msg": " you are registered"}
     else:
         return {"status": "error", "msg": "you have already registered"}
示例#4
0
    def get(self, user_id, confirmation_code):
        user = Users.get_by_id(int(user_id))

        if user.confirmation_code == confirmation_code:
            user.confirmed_email = True
            user.put()

        self.render('user_profile/account_home.html')
 def check_user_logged_in(self):
     if self.request.cookies.get('User'):
         user_id = self.read_cookie('User')
         if user_id:
             from models.users import Users
             return Users.get_by_id(int(user_id))
         else:
             return None
     return None
示例#6
0
 def check_user_logged_in(self):
     if self.request.cookies.get('User'):
         user_id = self.read_cookie('User')
         if user_id:
             from models.users import Users
             return Users.get_by_id(int(user_id)) #wrap in int()
         else:
             return None
     return None
    def get(self, user_id, confirmation_code):
        user = Users.get_by_id(int(user_id))

        if user:
            if user.confirmation_code == confirmation_code:
                user.confirmed_email = True
                user.put()

        self.redirect('/login')
示例#8
0
 def check_cookie(self):
     msg = self.request.cookies.get('user_id')
     if msg:
         user_id = msg.split('|')[0]
         user_hash = msg.split('|')[1]
         check_hash = hmac.new(secret, user_id).hexdigest()
         if user_hash == check_hash:
             return Users.get_by_id(int(user_id))
     else:
         return None
示例#9
0
 def logged_in_user_status(self):
     if self.request.cookies.get('User'):
         #GET THE COOKIE VALUE
         id = self.read_cookie('User')
         #CHECK THE STATUS OF THE COOKIE
         if id:
             from models.users import Users
             #RETURN THE USER
             return Users.get_by_id(int(id))
         else:
             return None
     return None