Exemplo n.º 1
0
def redirectDbAdmin(db_id):
    if len(db_id) == 0:
        flash('[db_id]パラメータを入れてください')
        return render_template('error/404.html')
    # データベースオブジェクトを取得する
    current_db = app.lib.cms_lib.session.get_current_db(db_id)
    # グローバル変数に設定する
    app.lib.cms_lib.session.current_db = current_db

    if current_db is None:
        flash('[db_id:{}]情報を取得できません'.format(db_id))
        return render_template('error/404.html')
    StrUtil.print_debug("db_adm_login_required. cur_db.db_id=[{}]".format(
        str(current_db.db_id)))

    if current_user.is_active:
        session['last_login_user_id'] = current_user.get_id()
        return set_cookie(
            StrUtil.get_safe_config(current_app, 'CMS_DB_SYS_COOKIE'),
            current_user.tuid, url_for('db_adm_index', db_id=db_id))

    form = LoginForm()
    # ログイン情報を保持する
    last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id',
                                                    session)
    user_id = request.args.get('user_id') or last_login_user_id
    if user_id:
        form.user_id.data = user_id

    return render_template('cms_admin/login.html',
                           form=form,
                           db_id=db_id,
                           db_name=current_db.db_name,
                           systemVersion="Developer Version 1.00")
Exemplo n.º 2
0
def doDbAdminLogin(db_id, form):
    if len(db_id) == 0:
        flash('[db_id]パラメータを入れてください')
        return render_template('error/404.html')

    # データベースオブジェクトを取得する
    current_db = app.lib.cms_lib.session.get_current_db(db_id)

    # グローバル変数に設定する
    app.lib.cms_lib.session.current_db = current_db

    if current_db is None:
        flash('[db_id:{}]情報を取得できません'.format(db_id))
        return render_template('error/404.html')
    StrUtil.print_debug("db_adm_login_required. cur_db.db_id=[{}]".format(
        str(current_db.db_id)))

    # リダイレクトURLを取得する
    next_url = _get_next_url()

    if form.validate_on_submit():
        user = User.query.filter_by(tuid=form.user_id.data).first()
        if user is None or not PkgUserAuth.check_passwd_for_cms(
                form.user_id.data, form.password.data):
            # エラーログを記録する
            pkgCmsErrLog = PkgCmsErrLog()
            pkgCmsErrLog.saveErrLog('LOGIN_ERROR', str(form.user_id.data),
                                    str(current_db.db_id), '')
            db.session.commit()
            flash('invalid user_id or password')
            return redirect(
                url_for('db_adm_login',
                        db_id=db_id,
                        user_id=form.user_id.data,
                        next_url=next_url))
        login_user(user, False)
        session['last_login_user_id'] = form.user_id.data

        return set_cookie(
            StrUtil.get_safe_config(current_app, 'CMS_DB_SYS_COOKIE'),
            current_user.tuid, url_for('db_adm_index', db_id=db_id))

    # ログイン情報を保持する
    last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id',
                                                    session)
    user_id = request.args.get('user_id') or last_login_user_id
    if user_id:
        form.user_id.data = user_id

    return render_template('cms_db_admin/login.html',
                           form=form,
                           db_id=db_id,
                           db_name=current_db.db_name,
                           next_url=next_url,
                           systemVersion="Developer Version 1.00")
Exemplo n.º 3
0
def swhEditMode():
    db_id = app.lib.cms_lib.session.get_db_id()
    if db_id + '_is_edit_mode' in session:
        if StrUtil.get_safe_edit_mode(str(db_id) + '_is_edit_mode', session):
            session[str(db_id) + '_is_edit_mode'] = False
        else:
            cmsSecurity = PkgCmsSecurity()
            if cmsSecurity.isDbEditable(db_id, current_user.get_id()) == False:
                return render_template('error/noPrivs.html',
                                       errorMsg='編集権限がありません。')

            session[str(db_id) + '_is_edit_mode'] = True
    else:
        session[str(db_id) + '_is_edit_mode'] = False

    return redirect(url_for('index', db_id=db_id, jtree_store='keep'))
Exemplo n.º 4
0
def doAdminLogin(form):
    # リダイレクトURLを取得する
    next_url = _get_next_url()

    if form.validate_on_submit():
        user = User.query.filter_by(tuid=form.user_id.data).first()
        if user is None or not PkgUserAuth.check_passwd_for_cms(
                form.user_id.data, form.password.data):
            # エラーログを記録する
            pkgCmsErrLog = PkgCmsErrLog()
            pkgCmsErrLog.saveErrLog('LOGIN_ERROR', str(form.user_id.data), '',
                                    '')
            db.session.commit()
            flash('invalid user_id or password')
            return redirect(
                url_for('adm_login',
                        user_id=form.user_id.data,
                        next_url=next_url))
        login_user(user, False)
        session['last_login_user_id'] = form.user_id.data

        return set_cookie(
            StrUtil.get_safe_config(current_app, 'CMS_SYS_COOKIE'),
            current_user.tuid, url_for('adm_index'))

    # ログイン情報を保持する
    last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id',
                                                    session)
    user_id = request.args.get('user_id') or last_login_user_id
    if user_id:
        form.user_id.data = user_id

    return render_template('cms_admin/login.html',
                           form=form,
                           next_url=next_url,
                           systemVersion="Developer Version 1.00")
Exemplo n.º 5
0
def main_init(db_id, request):
    if len(db_id) == 0:
        return render_template('error/404.html')

    db_name = ""
    information_message = ""
    # TODO result_cnt
    result_cnt = 0

    if app.lib.cms_lib.session.current_db:
        db_name = app.lib.cms_lib.session.current_db.db_name
        information_message = app.lib.cms_lib.session.current_db.information_message
        StrUtil.print_debug(
            'main_init. db_name:{0} information_message:{1}'.format(
                db_name, information_message))

    db_id = app.lib.cms_lib.session.current_db.db_id
    cmsSecurity = PkgCmsSecurity()
    is_db_editable = cmsSecurity.isDbEditable(db_id, current_user.get_id())

    # タブ情報を取得
    viewType = request.args.get('view_type')
    cmsTreeViewSetting = CmsTreeViewSetting()
    tabList = cmsTreeViewSetting.getTreeViewSettingList(db_id)
    if viewType is None or len(viewType) <= 0:
        treeSetting = cmsTreeViewSetting.getTreeViewSettingList(db_id).first()
        viewType = treeSetting.view_type
        treeOpenFlg = treeSetting.tree_open_flg
    else:
        treeSetting = cmsTreeViewSetting.getTreeViewSetting(db_id, viewType)
        treeOpenFlg = treeSetting.tree_open_flg

    jtree_store = ''
    selected_node_id = ''
    if request.method == 'GET':
        jtree_store = request.args.get('jtree_store') or ''
        selected_node_id = request.args.get('selected_node_id') or ''

    # 通常検索機能
    searchSetting = CmsSearchSetting().getSearchSettingByDbId(db_id)

    # 画面表示用CSS STYLEを取得
    colorSettingDic = CmsStyleMaster().getStyleSettings(
        db_id, Const.STYLE_TYPE_COLOR)

    return render_template(
        'main.html',
        title=db_name,
        view_type=viewType,
        tree_open_flg=treeOpenFlg,
        db_id=db_id,
        db_name=db_name,
        information_message=information_message,
        result_cnt=result_cnt,
        current_user=current_user,
        jtree_store=jtree_store,
        selected_node_id=selected_node_id,
        is_edit_mode=StrUtil.get_safe_edit_mode(
            str(db_id) + '_is_edit_mode', session),
        is_db_editable=is_db_editable,
        tabList=tabList,
        searchSetting=searchSetting,
        colorSettingDic=colorSettingDic,
        appVer=current_app.config['APP_VER'],
        is_db_admin_user=isDbAdminUser(str(db_id), str(current_user.get_id())),
    )
Exemplo n.º 6
0
def doLogin(db_id, form):
    if len(db_id) == 0:
        flash('[db_id]パラメータを入れてください')
        return render_template('error/404.html')

    # データベースオブジェクトを取得する
    current_db = app.lib.cms_lib.session.get_current_db(db_id)

    # グローバル変数に設定する
    app.lib.cms_lib.session.current_db = current_db

    if current_db is None:
        flash('[db_id:{}]情報を取得できません'.format(db_id))
        return render_template('error/404.html')
    StrUtil.print_debug("login_required. cur_db.db_id=[{}]".format(
        str(current_db.db_id)))

    # リダイレクトURLを取得する
    next_url = _get_next_url()

    if form.validate_on_submit():
        user = User.query.filter_by(tuid=form.user_id.data).first()
        if user is None or not PkgUserAuth.check_passwd_for_cms(
                form.user_id.data, form.password.data):
            # エラーログを記録する
            pkgCmsErrLog = PkgCmsErrLog()
            pkgCmsErrLog.saveErrLog('LOGIN_ERROR', str(form.user_id.data),
                                    str(current_db.db_id), '')
            db.session.commit()
            flash('invalid user_id or password')
            return redirect(
                url_for('login',
                        db_id=db_id,
                        user_id=form.user_id.data,
                        next_url=next_url))
        login_user(user, False)
        session['last_login_user_id'] = form.user_id.data
        session[str(db_id) + '_is_edit_mode'] = False

        # ログインログを記録する
        pkgCmsLog = PkgCmsLog()
        pkgCmsLog.saveOperationLog(form.user_id.data,
                                   db_id,
                                   operation_cd=Const.OPERATION_CD_LOGIN,
                                   object_type='DB',
                                   note=current_db.db_name)
        db.session.commit()
        return set_cookie(current_db.session_cookie_name, current_user.tuid,
                          url_for('index', db_id=db_id))

    # ログイン情報を保持する
    last_login_user_id = StrUtil.get_safe_edit_mode('last_login_user_id',
                                                    session)
    user_id = request.args.get('user_id') or last_login_user_id
    if user_id:
        form.user_id.data = user_id

    user_name = ''
    if current_user.is_active:
        user_name = current_user.get_user_name()

    return render_template(
        'login.html',
        title=current_db.db_name + '-ログイン画面',
        systemVersion="Developer Version 1.00",
        form=form,
        db_id=db_id,
        next_url=next_url,
        db_name=current_db.db_name,
        user_name=user_name,
        loginMessage=current_db.login_message,
    )