Beispiel #1
0
 def get_or_create_user(self, posted_data):
     """
     This session checks if the user with the facebook info already exists.
     If he exists, we update his facebook details and start a new session
     Else we create a new user and start a session for him
     """
     user = self.user_model.get_by_fb_id(posted_data["fb_id"])
     if user:
         self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
     else:
         try:
             user=UserManager.create_student(posted_data)
             self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
             self.send_verifaction_email_to_user()
          
         except UserAlreadyExistError:
             user = self.user_model.get_by_auth_id(posted_data["email"])
             if not user:
                 raise UserAlreadyExistError('A user with the u_email provided already exists')
             user.edit({'facebook_link':posted_data['facebook_link'], 'fb_access_token':posted_data['fb_access_token'], 'fb_id':posted_data['fb_id']})
             self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
Beispiel #2
0
 def validate_and_signup_user(self):
     self.validate_form()
     posted_data = self.get_required_posted_data()
     user=UserManager.create_student(posted_data)
     self.auth.set_session(self.auth.store.user_to_dict(user), remember=False)
     self.send_verifaction_email_to_user()