Exemplo n.º 1
0
def verify_mail():
    """
    """
    email = request.form.get('email', '')
    password = request.form.get('password', '')
    password = generate_password_hash(password)

    account_obj = _get_account_by_email(g._db, email)
    if account_obj:
        raise MainException.ACCOUNT_DUPLICATE

    code = random_ascii_string(40)

    appid = config.KEFU_APPID
    db = g._db

    mode = 1  #fix_mode
    db.begin()
    store_id = Store.create_store(db, '', 0, mode, 0)
    account_id = Seller.add_seller(db, email, password, store_id, email, 0)
    Account.insert_verify_email(db, email, code, EmailUsageType.SELLER_VERIFY,
                                account_id)
    db.commit()

    Store.add_seller_id(g.im_rds, store_id, account_id)

    if 'user' not in session:
        session['user'] = {}

    session['user']['id'] = account_id
    session['user']['email'] = email
    session['user']['email_checked'] = 0
    session['user']['store_id'] = store_id
    session['user']['name'] = email

    account = {
        "id": account_id,
        "email": email,
        "email_checked": 0,
    }

    send_verify_email(email,
                      code,
                      email_cb=url_for('account.register_valid',
                                       code='',
                                       _external=True))

    return send_response(account)
Exemplo n.º 2
0
def add_seller(store_id):
    rds = g.im_rds
    db = g._imdb
    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    md5_password = form.get('md5_password', '')
    salt = form.get('salt', '')
    number = form.get('number', '')
    is_password_empty = not password and (not md5_password or not salt)

    if not name or is_password_empty or not store_id:
        return INVALID_PARAM()
        
    if not number:
        number = None

    if password:
        password = generate_password_hash(password)
    elif md5_password:
        password = "******"%(salt,md5_password)

    logging.debug("seller name:%s number:%s password md5:%s", name, number, md5_password)
    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, number)
    if group_id:
        Group.add_group_member(db, group_id, seller_id)
    db.commit()

    Store.add_seller_id(rds, store_id, seller_id)

    if group_id:
        content = "%d,%d"%(group_id, seller_id)
        publish_message(g.im_rds, "group_member_add", content)

    obj = {"seller_id":seller_id}
    return make_response(200, obj)
Exemplo n.º 3
0
def store_seller_post(store_id):
    """
    store 添加商店人员

    """
    db = g._imdb
    rds = g.im_rds
    developer_id = session['user']['id']

    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    number = form.get('number', '')

    if not name or not password or not store_id:
        return INVALID_PARAM()

    if not number:
        number = None

    password = generate_password_hash(password)
    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, group_id,
                                  number)
    if group_id:
        Group.add_group_member(db, group_id, seller_id)
    db.commit()

    Store.add_seller_id(rds, store_id, seller_id)

    if group_id:
        content = "%d,%d" % (group_id, seller_id)
        publish_message(g.im_rds, "group_member_add", content)

    return redirect(url_for('.store_seller', store_id=store_id))
Exemplo n.º 4
0
def store_seller_post(store_id):
    """
    store 添加商店人员

    """
    db = g._imdb
    rds = g.im_rds
    developer_id = session['user']['id']

    form = request.form
    name = form.get('name', '')
    password = form.get('password', '')
    number = form.get('number', '')

    if not name or not password or not store_id:
        return INVALID_PARAM()
        
    if not number:
        number = None

    password = generate_password_hash(password)
    group_id = Store.get_store_gid(db, store_id)

    db.begin()
    seller_id = Seller.add_seller(db, name, password, store_id, group_id, number)
    if group_id:
        Group.add_group_member(db, group_id, seller_id)
    db.commit()

    Store.add_seller_id(rds, store_id, seller_id)

    if group_id:
        content = "%d,%d"%(group_id, seller_id)
        publish_message(g.im_rds, "group_member_add", content)
    
    return redirect(url_for('.store_seller', store_id=store_id))