def _processForbidden(self, e): if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth': return redirect_to_login( reason=_("Please log in to access this page.")) message = _("Access Denied") explanation = get_error_description(e) return render_error(message, explanation)
def _processModificationError(self, e): """Handles modification errors occured during the process of a RH.""" if not session.user: return redirect_to_login(reason=_( "Please log in to access this page. If you have a modification key, you " "may enter it afterwards.")) return WPModificationError(self).display()
def _processForbidden(self, e): if session.user is None and not request.is_xhr and not e.response: return redirect_to_login( reason=_("Please log in to access this page.")) message = _("Access Denied") explanation = get_error_description(e) return WErrorWSGI((message, explanation)).getHTML()
def _require_user(self): if session.user is None: raise Forbidden(response=redirect_to_login(reason=_('You are trying to sign an agreement that requires ' 'you to be logged in'))) if self.agreement.user != session.user: raise Forbidden(_('Please log in as {name} to sign this agreement.') .format(name=self.agreement.user.full_name))
def _checkProtection( self ): RHBaseEvaluation._checkProtection(self) if self._evaluation.inEvaluationPeriod() and self._evaluation.isMandatoryAccount() and not self._getUser(): flash(_("Please log in to access this event's evaluation form.")) self._redirect(redirect_to_login(reason=_("You are trying to participate in an evaluation that requires " "you to be logged in."))) self._doProcess = False
def _checkSessionUser(self): if session.user is None: raise Forbidden(response=redirect_to_login(reason=_('You are trying to sign an agreement that requires ' 'you to be logged in'))) if self.agreement.user != session.user: raise Forbidden(_('Please log in as {name} to sign this agreement.') .format(name=self.agreement.user.full_name))
def _checkProtection(self): RHRegistrationFormRegistrationBase._checkProtection(self) if self.regform.require_login and not session.user and request.method != "GET": raise Forbidden( response=redirect_to_login( reason=_("You are trying to register with a form " "that requires you to be logged in") ) )
def _check_access(self): RHSurveyBaseDisplay._check_access(self) if self.survey.require_user and not session.user: raise Forbidden(response=redirect_to_login(reason=_('You are trying to answer a survey ' 'that requires you to be logged in'))) if self.survey.private and request.args.get('token') != self.survey.uuid and not self.submission: # We don't use forbidden since that would redirect to login - but logging in won't help here raise NotFound
def handle_forbidden(exc): if exc.response: return exc if session.user is None and not request.is_xhr and request.blueprint != 'auth': return redirect_to_login( reason=_('Please log in to access this page.')) return render_error(exc, _('Access Denied'), get_error_description(exc), exc.code)
def _checkProtection(self): RHSurveyBaseDisplay._checkProtection(self) if self.survey.require_user and not session.user: raise Forbidden(response=redirect_to_login(reason=_('You are trying to answer a survey ' 'that requires you to be logged in'))) if self.survey.private and request.args.get('token') != self.survey.uuid and not self.submission: # We don't use forbidden since that would redirect to login - but logging in won't help here raise NotFound
def _checkProtection(self): RHSurveyBaseDisplay._checkProtection(self) if self.survey.require_user and not session.user: raise Forbidden( response=redirect_to_login( reason=_("You are trying to answer a survey " "that requires you to be logged in") ) )
def _checkProtection(self): RHRegistrationFormDisplayBase._checkProtection(self) if self._regForm.inRegistrationPeriod() and self._regForm.isMandatoryAccount() and self._getUser() is None: self._redirect( redirect_to_login( reason=_("You are trying to register for an event that requires you to be " "logged in.") ) ) self._doProcess = False
def _processModificationError(self, e): """Handles modification errors occured during the process of a RH.""" # Redirect to HTTPS in case the user is logged in self._tohttps = True if self._checkHttpsRedirect(): return if not session.user: return redirect_to_login(reason=_("Please log in to access this page. If you have a modification key, you " "may enter it afterwards.")) return errors.WPModificationError(self).display()
def _process(self): if not session.user: return redirect_to_login(next_url=url_for_plugin( 'vc_bbb.start_and_join', self.event_vc_room), reason='Please, identify yourself') create_url = get_create_meeting_url(self.vc_room, self.event_vc_room) is_moderator = list( session.user.as_principal) in self.event_vc_room.data['moderators'] join_url = get_join_url(self.vc_room, is_moderator) if is_meeting_running(self.vc_room): return redirect(join_url) if not is_moderator: return redirect(url_for('vc.event_videoconference', self.event)) try: files = self.event_vc_room.data['file'] except KeyError: files = None if files and len(files): xml = "<?xml version='1.0' encoding='UTF-8'?><modules>" for f in files: xml += "<module name=\"presentation\"><document name=\"" + f[ 'filename'] + "\">" + f['content'] + "</document></module>" xml += "</modules>" r = requests.put(create_url, data=xml, headers={'Content-type': 'application/xml'}) else: r = requests.get(create_url) root = ET.fromstring(r.content) status = root.find('returncode').text if status == 'SUCCESS': internal_id = root.find('internalMeetingID').text try: running = internal_id in self.event_vc_room.data[ 'internal_id_list'] except KeyError: self.event_vc_room.data['internal_id_list'] = [internal_id] running = False else: if not running: self.event_vc_room.data['internal_id_list'].append( internal_id) flag_modified(self.event_vc_room, 'data') return redirect(join_url) else: raise VCRoomError(_("Cannot create room")) return jsonify_data(flash=False)
def _check_access(self): RHRegistrationFormRegistrationBase._check_access(self) if self.regform.require_login and not session.user and request.method != 'GET': raise Forbidden(response=redirect_to_login( reason=_('You are trying to register with a form ' 'that requires you to be logged in')))
def _check_access(self): RHRegistrationFormRegistrationBase._check_access(self) if self.regform.require_login and not session.user and request.method != 'GET': raise Forbidden(response=redirect_to_login(reason=_('You are trying to register with a form ' 'that requires you to be logged in')))
def test2(): from werkzeug.exceptions import Forbidden from indico.modules.auth.util import redirect_to_login raise Forbidden(response=redirect_to_login( reason='YOU SHALL NOT PASS WITHOUT LOGGING IN'))
def _processForbidden(self, e): if session.user is None and not request.is_xhr and not e.response: return redirect_to_login(reason=_("Please log in to access this page.")) message = _("Access Denied") explanation = get_error_description(e) return WErrorWSGI((message, explanation)).getHTML()
def _checkProtection(self): RHSurveyBaseDisplay._checkProtection(self) if self.survey.require_user and not session.user: raise Forbidden(response=redirect_to_login(reason=_('You are trying to answer a survey ' 'that requires you to be logged in')))
def _processForbidden(self, e): if session.user is None and not request.is_xhr and not e.response and request.blueprint != 'auth': return redirect_to_login(reason=_("Please log in to access this page.")) message = _("Access Denied") explanation = get_error_description(e) return render_error(message, explanation)
def handle_forbidden(exc): if exc.response: return exc if session.user is None and not request.is_xhr and request.blueprint != 'auth': return redirect_to_login(reason=_('Please log in to access this page.')) return render_error(exc, _('Access Denied'), get_error_description(exc), exc.code)