Beispiel #1
0
def register():
    login_form= LoginForm(next=request.args.get('next'))
    form = SignupForm(next=request.args.get('next'))

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)

        userDoc = current_app.dbapi.update_user_profile(user_id=form.name.data,
            name=form.name.data, email=form.email.data, 
            new_pw_hash=generate_password_hash(form.password.data),
            invitation_code=form.invitation_code.data,
            upsert=True,
            )
        #print userDoc
        #todo: check fail
        flash(_('You were successfully registered and can login now'))
        user, authenticated, error = User.authenticate(
            form.name.data, form.password.data)

        #print "You were successfully registered and can login now"

        if login_user(user):
           current_app.dbapi.add_note(author_id=current_user.id, source=default_note_source)
           return redirect(form.next.data or url_for('funnote.fastnote'))
            #return redirect( url_for('funnote.index') )
    else:
        pass
        #print "validate failed."

    return render_template('register.html', form=form, login_form=login_form)
Beispiel #2
0
def register():
    login_form = LoginForm(next=request.args.get('next'))
    form = SignupForm(next=request.args.get('next'))

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)

        userDoc = current_app.dbapi.update_user_profile(
            user_id=form.name.data,
            name=form.name.data,
            email=form.email.data,
            new_pw_hash=generate_password_hash(form.password.data),
            invitation_code=form.invitation_code.data,
            upsert=True,
        )
        #print userDoc
        #todo: check fail
        flash(_('You were successfully registered and can login now'))
        user, authenticated, error = User.authenticate(form.name.data,
                                                       form.password.data)

        #print "You were successfully registered and can login now"

        if login_user(user):
            current_app.dbapi.add_note(author_id=current_user.id,
                                       source=default_note_source)
            return redirect(form.next.data or url_for('funnote.fastnote'))
            #return redirect( url_for('funnote.index') )
    else:
        pass
        #print "validate failed."

    return render_template('register.html', form=form, login_form=login_form)
Beispiel #3
0
def funmark():
    login_form = signup_form = None
    if not current_user.is_authenticated():
        login_form= LoginForm(next=request.args.get('next'))
        signup_form = SignupForm(nex=request.args.get('next'))

    return render_template('md2img.html', 
        login_form=login_form,signup_form=signup_form)
Beispiel #4
0
def register():
    login_form= LoginForm(next=request.args.get('next'))
    form = SignupForm(next=request.args.get('next'))

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)

        user_doc = {"_id":form.name.data,
                    "email":form.email.data,
                    "pw_hash":generate_password_hash(form.password.data),
                    "copyrights":"user",
                    "reg_date":int(time.time())}
        g.db.users.insert(user_doc, safe=True)
        #todo: check fail
        flash('You were successfully registered and can login now')

        if login_user(user):
            return redirect(form.next.data or url_for('homesite.login'))

    return render_template('register.html', form=form, login_form=login_form)
Beispiel #5
0
def home():
    if request.url.find('ECNU') != -1 and request.url.find('www.ECNU') == -1:
        #print "redirect ECNU to www.ECNU."
        url = request.url.replace('ECNU', 'www.ECNU')
        return redirect(url)

    login_form = signup_form = None
    if not current_user.is_authenticated():
        login_form = LoginForm(next=request.args.get('next'))
        signup_form = SignupForm(nex=request.args.get('next'))

    return render_template('index.html',
                           login_form=login_form,
                           signup_form=signup_form)