예제 #1
0
def register():
    try:
        check_form_para(['nickname', 'email', 'password', 'password_conf', 'gender'])
        assert request.form['password'] == request.form['password_conf'], u'两次密码输入不一致,请重新输入'
    except AssertionError, e:
        if e.message:
            flash(e.message)
        else :
            flash(u'请输入所有信息')
        return redirect(url_for('home.intro', regis_error=1))
예제 #2
0
def login():
    try:
        check_form_para(['email', 'password'])
    except AssertionError:
        flash(u'请输入邮箱和密码')
        return redirect(url_for('home.intro', login_error=1))

    user_to_login = UserHelper.get_by_email(request.form['email'])
    if user_to_login == None or not UserHelper.verify_password(user_to_login, request.form['password']):
        flash(u'无效的邮箱或密码')
        return redirect(url_for('home.intro', login_error=1))
    
    is_remember = False if 'remember_me' not in request.form else True

    login_user(user_to_login, remember=is_remember)
    return redirect(url_for('home.home'))
예제 #3
0
def add_attach(route_id):
    try:
        route_id = ObjectId(route_id)
        assert RouteHelper.get(route_id)
        assert not RouteHelper.get(route_id).finished
    except :
        flash('invalid route_id')
        return redirect(url_for('home.home'))

    route = RouteHelper.get(route_id)
    
    if route.author != current_user.id:
        flash('you are not the author of the route')
        return redirect(url_for('home.home'))

    try:
        check_form_para(['key', 'type'])
    except AssertionError, e:
        flash(e.message)
        return redirect(url_for('route.add_attach_page', route_id=route.id))
예제 #4
0
def modify_password():
    try:
        assert check_form_para(['old_password', 'new_password', 'new_password_conf'])
        assert UserHelper.verify_password(current_user, request.form['old_password'])
    except AssertionError, e:
        flash(e.message)