Beispiel #1
0
def index():
    """ Renders homepage. """

    # legacy app support
    c = request.values.get('c')
    if c == current_app.config['CFG_SITE_NAME']:
        return redirect(url_for('.index', ln=g.ln))
    elif c is not None:
        return redirect(url_for('.collection', name=c, ln=g.ln))

    collection = Collection.query.get_or_404(1)

    from invenio.b2share.modules.b2deposit.latest_deposits import get_latest_deposits
    latest_deposits = get_latest_deposits()

    func = current_app.config.get("CFG_SITE_FUNCTION") or ""

    @register_template_context_processor
    def index_context():
        return dict(
            of=request.values.get('of', collection.formatoptions[0]['code']),
            easy_search_form=EasySearchForm(csrf_enabled=False),
            format_record=format_record,
        )

    return dict(collection=collection,
                latest_deposits=latest_deposits,
                pagetitle="EUDAT B2SHARE",
                site_function=func)
Beispiel #2
0
def index():
    """ Renders homepage. """

    # legacy app support
    c = request.values.get('c')
    if c == current_app.config['CFG_SITE_NAME']:
        return redirect(url_for('.index', ln=g.ln))
    elif c is not None:
        return redirect(url_for('.collection', name=c, ln=g.ln))

    collection = Collection.query.get_or_404(1)

    from invenio.b2share.modules.b2deposit.latest_deposits import get_latest_deposits
    latest_deposits = get_latest_deposits()

    func = current_app.config.get("CFG_SITE_FUNCTION") or ""

    @register_template_context_processor
    def index_context():
        return dict(
            of=request.values.get('of', collection.formatoptions[0]['code']),
            easy_search_form=EasySearchForm(csrf_enabled=False),
            format_record=format_record,
        )
    return dict(collection=collection,latest_deposits=latest_deposits, pagetitle="EUDAT B2SHARE",site_function=func)
Beispiel #3
0
def login(nickname=None, password=None, login_method=None, action='',
          remember=False, referer=None):
    if cfg.get('CFG_ACCESS_CONTROL_LEVEL_SITE') > 0:
        return abort(401)  # page is not authorized

    if action:
        from invenio.modules.access.mailcookie import \
            InvenioWebAccessMailCookieError, \
            mail_cookie_check_authorize_action
        try:
            action, arguments = mail_cookie_check_authorize_action(action)
        except InvenioWebAccessMailCookieError:
            pass
    form = LoginForm(CombinedMultiDict(
        [ImmutableMultiDict({'referer': referer, 'login_method': 'Local'}
                            if referer else {'login_method': 'Local'}),
         request.values]), csrf_enabled=False)

    collection = Collection.query.get_or_404(1)

    from invenio.b2share.modules.b2deposit.latest_deposits import get_latest_deposits
    latest_deposits = get_latest_deposits()

    if request.method == "POST":
        try:
            if login_method == 'Local' and form.validate_on_submit() and \
               authenticate(nickname, password, login_method=login_method,
                            remember=remember):
                flash(
                    _("You are logged in as %(nick)s.", nick=nickname),
                    "success"
                )
                return login_redirect(referer)
            else:
                flash(_("Invalid credentials."), "error")
        except Exception as e:
            current_app.logger.error(
                'Exception during login process: %s', str(e)
            )
            flash(_("Problem with login."), "error")

    return render_template('accounts/login.html', collection=collection, form=form, latest_deposits=latest_deposits)
Beispiel #4
0
def login(nickname=None, password=None, login_method=None, action='',
          remember=False, referer=None):
    if cfg.get('CFG_ACCESS_CONTROL_LEVEL_SITE') > 0:
        return abort(401)  # page is not authorized

    if action:
        from invenio.modules.access.mailcookie import \
            InvenioWebAccessMailCookieError, \
            mail_cookie_check_authorize_action
        try:
            action, arguments = mail_cookie_check_authorize_action(action)
        except InvenioWebAccessMailCookieError:
            pass
    form = LoginForm(CombinedMultiDict(
        [ImmutableMultiDict({'referer': referer, 'login_method': 'Local'}
                            if referer else {'login_method': 'Local'}),
         request.values]), csrf_enabled=False)

    collection = Collection.query.get_or_404(1)

    from invenio.b2share.modules.b2deposit.latest_deposits import get_latest_deposits
    latest_deposits = get_latest_deposits()

    if request.method == "POST":
        try:
            if login_method == 'Local' and form.validate_on_submit() and \
               authenticate(nickname, password, login_method=login_method,
                            remember=remember):
                flash(
                    _("You are logged in as %(nick)s.", nick=nickname),
                    "success"
                )
                return login_redirect(referer)
            else:
                flash(_("Invalid credentials."), "error")
        except Exception as e:
            current_app.logger.error(
                'Exception during login process: %s', str(e)
            )
            flash(_("Problem with login."), "error")

    return render_template('accounts/login.html', collection=collection, form=form, latest_deposits=latest_deposits)