Ejemplo n.º 1
0
 def post(self):
     try:
         self.validate_and_signup_user()
         print(self.request.get('callback'))
         if(self.request.get('callback') and is_good_callback(self.request.get('callback'), self.request.host_url)):   
             self.send_success_response({'redirect':True})
         else:
             self.send_success_response({'redirect':False})
     except InvalidFormError as e:
         self.send_failed_response(error=e)
     except UserAlreadyExistError as e:
         self.send_failed_response(error=e)
     finally:
         print("host : " + self.request.host_url + " " +self.request.get('callback') +" status: "+ str(is_good_callback(self.request.get('callback'), self.request.host_url)))
Ejemplo n.º 2
0
 def post(self):
     try:
         self.validate_form()
         posted_data = self.get_required_posted_data()
         access_token = self.get_fb_access_token()
         posted_data.update(self.get_all_required_data_from_fb(access_token))
         self.get_or_create_user(posted_data)
         if(self.request.get('callback') and is_good_callback(self.request.get('callback'), self.request.host_url)):
             self.send_success_response({'redirect':True})
         else:
             self.send_success_response({'redirect':False})
     except InvalidFormError as e:
         self.send_failed_response(error=e)
     except UserAlreadyExistError as e:
         self.send_failed_response(error=e)
     except facebook.GraphAPIError as e:
         self.abort(403)
         
 
         
Ejemplo n.º 3
0
 def post(self):
     posted_data = self.cleanPostedData(['email', 'password', 'remember_me'])
     username = posted_data.get('email')
     password = posted_data.get('password')
     if posted_data.get('remember_me'):
         remember = True
     else:
         remember = False
     try:
         self.auth.get_user_by_password(username, password, remember=remember,
             save_session=True)
         callback = self.request.get('callback');
         if callback and helpers.is_good_callback(callback, self.request.host_url):
             self.redirect(str(callback))
         else:
             
             self.redirect(self.uri_for('marketMain'))
             
         
     except (InvalidAuthIdError, InvalidPasswordError) as e:
         logging.info('Login failed for user %s because of %s', username, type(e))
         self.redirect(self.uri_for('marketAuthenticate', d=1))
Ejemplo n.º 4
0
    def get(self):
        callback = self.request.get('callback')
        try:
            cookie = facebook.get_user_from_cookie(self.request.cookies,
                                                   FACEBOOK_APP_ID,
                                                   FACEBOOK_APP_SECRET)
            if cookie:


                logging.info(cookie)

                firstname = cookie.get("first_name")

                user = self.user_model.get_by_fb_id(cookie["uid"])
                if user:
                    self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
                    if callback and is_good_callback(callback):
                        self.redirect(str(callback))
                    self.redirect(self.uri_for("marketMain"))
                else:
                    graph = facebook.GraphAPI(cookie["access_token"])
                    profile = graph.get_object("me")
                    user = self.user_model.get_by_auth_id(profile["email"])
                    if user:
                        profile['access_token'] = graph.extend_access_token(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET)['access_token']
                        user.edit({'facebook_link':profile['link'], 'fb_access_token':profile['access_token'], 'fb_id':profile['id']})
                        self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
                        self.redirect(self.uri_for("marketMain"))
                    else:
                        self.render_template('facebook_signup_landing.html', {'first_name':firstname, 'callback':callback})
            else:        
               
                self.render_template('facebook_signup_landing.html', {'callback': callback})
                
        except facebook.GraphAPIError as e:
            logging.info(e)
            self.render_template('facebook_signup_landing.html', {'callback':callback})