def index(): """ Renders homepage. """ collection = Collection.query.get_or_404(1) print "Aaa"+g.ln; print "<p>Aaa"+g.ln+"</p>"; from invenio.b2share_utils import get_latest_deposits latest_deposits = get_latest_deposits() # inject functions to the template @register_template_context_processor def index_context(): return dict( easy_search_form=EasySearchForm(csrf_enabled=False), format_record=cached_format_record, get_creation_date=get_creation_date, unregistered=(not current_user.is_authenticated()) ) return dict(collection=collection, latest_deposits=latest_deposits)
def login(nickname=None, password=None, login_method=None, action='', remember_me=False, referer=None): if CFG_ACCESS_CONTROL_LEVEL_SITE > 0: return abort(401) # page is not authorized if action: try: action, arguments = mail_cookie_check_authorize_action(action) except InvenioWebAccessMailCookieError: pass form = LoginForm(CombinedMultiDict([ImmutableMultiDict({'referer': referer} if referer else {}), request.values]), csrf_enabled=False) try: user = None if not CFG_EXTERNAL_AUTH_USING_SSO: if login_method == 'Local': if form.validate_on_submit(): user = update_login(nickname, password, remember_me) elif login_method in ['openid', 'oauth1', 'oauth2']: pass req = request.get_legacy_request() (iden, nickname, password, msgcode) = webuser.loginUser(req, nickname, password, login_method) if iden: user = update_login(nickname) else: flash(_('Invalid login method.'), 'error') else: req = request.get_legacy_request() # Fake parameters for p_un & p_pw because SSO takes them from the environment (iden, nickname, password, msgcode) = webuser.loginUser(req, '', '', CFG_EXTERNAL_AUTH_USING_SSO) if iden: user = update_login(nickname) if user: flash(_("You are logged in as %s.") % user.nickname, "info") if referer is not None: from urlparse import urlparse # we should not redirect to these URLs after login blacklist = [url_for('webaccount.register'), url_for('webaccount.logout'), url_for('webaccount.login')] if not urlparse(referer).path in blacklist: # Change HTTP method to https if needed. referer = referer.replace(CFG_SITE_URL, CFG_SITE_SECURE_URL) return redirect(referer) return redirect('/') except: flash(_("Problem with login."), "error") current_app.config.update(dict((k, v) for k, v in vars(websession_config).iteritems() if "CFG_" == k[:4])) collection = Collection.query.get_or_404(1) from invenio.b2share_utils import get_latest_deposits latest_deposits = get_latest_deposits() # @register_template_context_processor # def index_context(): # return dict( # easy_search_form=EasySearchForm(csrf_enabled=False), # format_record=cached_format_record, # get_creation_date=get_creation_date, # unregistered=(not current_user.is_authenticated()) # ) return render_template('webaccount_login.html', form=form, collection=collection, latest_deposits=latest_deposits)