コード例 #1
0
ファイル: views.py プロジェクト: CAS-IT/ILSTUViews
    def register_post():
        if current_user.is_authenticated():
            return redirect("/")

        current_app.logger.debug('Attempting to register a user')

        # Always clear out any verified phone numbers
        #session.pop('verified_phone', None)

        form = UserRegistrationForm()

        if form.validate():
            # Register the user
            user = cdw.register_website_user(
                form.username.data, form.email.data, form.password.data,
                session.pop('verified_phone', None))

            # Try connecting their facebook account if a token
            # is in the session
            try:
                handler = current_app.social.facebook.connect_handler

                conn = handler.get_connection_values(
                    {"access_token": session['facebooktoken']})

                conn['user_id'] = str(user.id)
                current_app.logger.debug('Saving connection: %s' % conn)
                connection_service.save_connection(**conn)
            except KeyError, e:
                current_app.logger.error(e)
                pass
            except Exception, e:
                current_app.logger.error(
                    'Could not save connection to Facebook: %s' % e)
コード例 #2
0
ファイル: views.py プロジェクト: Chiggins/ILSTUViews
    def register_post():
        if current_user.is_authenticated():
            return redirect("/")

        current_app.logger.debug("Attempting to register a user")

        # Always clear out any verified phone numbers
        # session.pop('verified_phone', None)

        form = UserRegistrationForm()

        if form.validate():
            # Register the user
            user = cdw.register_website_user(
                form.username.data, form.email.data, form.password.data, session.pop("verified_phone", None)
            )

            # Try connecting their facebook account if a token
            # is in the session
            try:
                handler = current_app.social.facebook.connect_handler

                conn = handler.get_connection_values({"access_token": session["facebooktoken"]})

                conn["user_id"] = str(user.id)
                current_app.logger.debug("Saving connection: %s" % conn)
                connection_service.save_connection(**conn)
            except KeyError, e:
                current_app.logger.error(e)
                pass
            except Exception, e:
                current_app.logger.error("Could not save connection to Facebook: %s" % e)
コード例 #3
0
ファイル: views.py プロジェクト: CAS-IT/ILSTUViews
    def register_email():
        if current_user.is_authenticated():
            return redirect("/")

        form = UserRegistrationForm()
        # You'd think this wouldn't need to be called here but
        # a CSRF error will come up when the form is POSTed to
        # /register. So below there's a show_errors flag in the
        # template context blow
        form.validate()

        # See if a password was passed from the register modal
        form.password.data = request.form.get('password', '')

        return render_template('register.html',
                               section_selector="register",
                               page_selector="email",
                               form=form,
                               show_errors=False,
                               phoneForm=VerifyPhoneForm(csrf_enabled=False))
コード例 #4
0
ファイル: views.py プロジェクト: AltisCorp/Civil-Debate-Wall
 def register_email():
     if current_user.is_authenticated():
         return redirect("/")
     
     form = UserRegistrationForm()
     # You'd think this wouldn't need to be called here but
     # a CSRF error will come up when the form is POSTed to 
     # /register. So below there's a show_errors flag in the
     # template context blow
     form.validate()
     
     # See if a password was passed from the register modal
     form.password.data = request.form.get('password', '')
     
     
     return render_template('register.html', 
                            section_selector="register", 
                            page_selector="email", 
                            form=form, 
                            show_errors=False,
                            phoneForm=VerifyPhoneForm(csrf_enabled=False))
コード例 #5
0
ファイル: views.py プロジェクト: AltisCorp/Civil-Debate-Wall
 def register_facebook():
     if current_user.is_authenticated():
         return redirect("/")
     # Always clear out any verified phone numbers
     session.pop('verified_phone', None)
     
     # Try getting their facebook profile
     profile = get_facebook_profile(session['facebooktoken'])
     
     phoneForm = VerifyPhoneForm(csrf_enabled=False)
     form = UserRegistrationForm(username=profile['first_name'], 
                                 email=profile['email'],
                                 csrf_enabled=False)
     
     form.password.data = request.form.get('password', '')
     form.validate()
     
     return render_template('register.html',
                            form=form, 
                            phoneForm=phoneForm,
                            facebook_profile=profile, 
                            show_errors=False,
                            section_selector="register", 
                            page_selector="facebook")
コード例 #6
0
ファイル: views.py プロジェクト: CAS-IT/ILSTUViews
    def register_facebook():
        if current_user.is_authenticated():
            return redirect("/")
        # Always clear out any verified phone numbers
        session.pop('verified_phone', None)

        # Try getting their facebook profile
        profile = get_facebook_profile(session['facebooktoken'])

        phoneForm = VerifyPhoneForm(csrf_enabled=False)
        form = UserRegistrationForm(username=profile['first_name'],
                                    email=profile['email'],
                                    csrf_enabled=False)

        form.password.data = request.form.get('password', '')
        form.validate()

        return render_template('register.html',
                               form=form,
                               phoneForm=phoneForm,
                               facebook_profile=profile,
                               show_errors=False,
                               section_selector="register",
                               page_selector="facebook")