当前位置: 首页>>代码示例>>Python>>正文


Python security.forget函数代码示例

本文整理汇总了Python中pyramid.security.forget函数的典型用法代码示例。如果您正苦于以下问题:Python forget函数的具体用法?Python forget怎么用?Python forget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forget函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: logout

 def logout(self):
     if 'redirect' in self.request.params:
         headers = forget(self.request)
         return HTTPFound(location=self.request.params.get('redirect'), headers=headers)
     else:
         headers = forget(self.request)
         return HTTPFound(location=route_url('menu', self.request), headers=headers)
开发者ID:hietpasd,项目名称:quizsmith,代码行数:7,代码来源:authentication.py

示例2: logout

	def logout(self):
		request = self.request

		forget(request)
		request.session['bypass_login'] = None

		return HTTPFound(location=request.route_url('login'))
开发者ID:OpenCIOC,项目名称:featuretracker,代码行数:7,代码来源:login.py

示例3: maybe_merge

def maybe_merge(
        backend, details, user=None, other_users=None,
        *args, **kwargs):
    # If we do not already have a user, see if we're in a situation
    # where we're adding an account to an existing user, and maybe
    # even merging
    request = backend.strategy.request
    adding_account = request.session.get("add_account", None)
    if adding_account is not None:
        del request.session["add_account"]
    # current discussion and next?
    logged_in = request.authenticated_userid
    if logged_in:
        logged_in = User.get(logged_in)
        if adding_account:
            if user and user != logged_in:
                # logged_in presumably newer?
                logged_in.merge(user)
                logged_in.db.delete(user)
                logged_in.db.flush()
            user = logged_in
        else:
            forget(request)
    if other_users:
        if not user:
            user = other_users.pop(0)
        # Merge other accounts with same verified email
        for profile in other_users:
            user.merge(profile)
            profile.delete()
    return {"user": user}
开发者ID:assembl,项目名称:assembl,代码行数:31,代码来源:social_auth.py

示例4: build_sync_client

def build_sync_client(request):
    # Get the BID assertion
    is_authorization_defined = AUTHORIZATION_HEADER in request.headers
    starts_with_browser_id = False
    if is_authorization_defined:
        authorization = request.headers[AUTHORIZATION_HEADER].lower()
        starts_with_browser_id = authorization.startswith("browserid")

    if not is_authorization_defined or not starts_with_browser_id:
        error_msg = "Provide a BID assertion %s header." % (
            AUTHORIZATION_HEADER)
        response = http_error(httpexceptions.HTTPUnauthorized(),
                              errno=ERRORS.MISSING_AUTH_TOKEN,
                              message=error_msg)
        response.headers.extend(forget(request))
        raise response

    is_client_state_defined = CLIENT_STATE_HEADER in request.headers
    if not is_client_state_defined:
        error_msg = "Provide the tokenserver %s header." % (
            CLIENT_STATE_HEADER)
        response = http_error(httpexceptions.HTTPUnauthorized(),
                              errno=ERRORS.MISSING_AUTH_TOKEN,
                              message=error_msg)
        response.headers.extend(forget(request))
        raise response

    authorization_header = request.headers[AUTHORIZATION_HEADER]

    bid_assertion = authorization_header.split(" ", 1)[1]
    client_state = request.headers[CLIENT_STATE_HEADER]
    sync_client = SyncClient(bid_assertion, client_state)
    return sync_client
开发者ID:Natim,项目名称:syncto,代码行数:33,代码来源:authentication.py

示例5: forbidden_view

def forbidden_view(request):
    loc = route_url('login', request, _query=(('next', request.path),))

    # tries to refresh the token
    refresh_token = request.session.get('refresh_token')
    if refresh_token:
        print 'refreshing token'
        payload = {}
        payload['refresh_token'] = refresh_token
        payload['client_id'] = request.registry.settings.get('alfresco.consumer_key')
        payload['client_secret'] = request.registry.settings.get('alfresco.consumer_secret')
        payload['grant_type'] = 'refresh_token'
        r = requests.post('https://api.alfresco.com/auth/oauth/versions/2/token',
                          data=payload)
        if r.status_code != 200:
            headers = forget(request)
            request.session.invalidate()
            return HTTPFound(location=loc, headers=headers)
        else:
            request.session['access_token'] = r.json()['access_token']
            request.session['refresh_token'] = r.json()['refresh_token']
            return HTTPFound(location=request.path)

    elif authenticated_userid(request):
        headers = forget(request)
        return HTTPFound(location=loc, headers=headers)
    return HTTPFound(location=loc)
开发者ID:RedTurtle,项目名称:pyramid_alfresco,代码行数:27,代码来源:views.py

示例6: get_avatar

def get_avatar(request):
    """
        Returns the current User object
    """
    logger.info("# Retrieving avatar #")
    login = request.unauthenticated_userid
    logger.info(u"  + Login : %s" % login)
    result = None
    if login is not None:
        logger.info("  + Returning the user")
        query = request.dbsession.query(User)
        query = query.join(Login)
        query = query.options(load_only("firstname", "lastname"))
        query = query.options(
            contains_eager(User.login).load_only('login').selectinload(
                Login._groups).load_only('name'),
            selectinload(User.companies).load_only('id', 'active'),
        )
        query = query.filter(Login.login == login)
        result = query.first()
        if result is None:
            forget(request)
            raise HTTPFound("/")
    else:
        logger.info("  + No user found")
    logger.debug(u"-> End of the avatar collection")
    return result
开发者ID:CroissanceCommune,项目名称:autonomie,代码行数:27,代码来源:avatar.py

示例7: anggaran_022_frm

    def anggaran_022_frm(self):
        req = self.request
        params = req.params
        url_dict = req.matchdict
        self.datas['id'] = 'id' in url_dict and int(url_dict['id']) or 0
        self.datas['pegawai_nama'] = 'pegawai_nama' in params and int(params['pegawai_nama']) or 0
        
        if self.logged and self.is_akses_mod('read'):
            if (not self.datas['id'] and self.is_akses_mod('add'))\
                or (self.datas['id'] and self.is_akses_mod('edit')):
                #row = KegiatanSubModel.get_by_id(self.datas['id'])
                row = DBSession.query(KegiatanSubModel).filter(KegiatanSubModel.id==self.datas['id']).first()
                if row:
                    rows = KegiatanSubModel.row2dict(row)
                    rows['unit_nm'] = row.units.nama
                    rows['kegiatan_nm'] = row.kegiatans.nama
                    return dict(datas=self.datas, rows=rows)
                else:
                    if self.datas['id']>0:
                        return HTTPNotFound() #TODO: Warning Data Not Found
                rows = {}
                #rows['tahun_id'] = self.datas['tahun']
                return dict(datas = self.datas,rows = '')
            else:
                return HTTPNotFound() #TODO: Warning Hak Akses 

        else:
            if not self.logged:
                headers=forget(self.request)
                return HTTPFound(location='/login?app=%s' % self.app, headers=headers)
            else:
                headers=forget(self.request)
                return HTTPFound(location='/anggaran', headers=headers)
开发者ID:aagusti,项目名称:osipkd-pdpt,代码行数:33,代码来源:anggaran.py

示例8: logout

def logout(request):
    logout_url = maybe_social_logout(request)
    forget(request)
    if logout_url:
        return HTTPFound(location=logout_url)
    next_view = handle_next_view(request, True)
    return HTTPFound(location=next_view)
开发者ID:assembl,项目名称:assembl,代码行数:7,代码来源:views.py

示例9: __render__

 def __render__(self):
     login_url = self.request.route_url('login')
     referrer = self.request.url
     if referrer == login_url:
         referrer = '/'  # never use login form itself as came_from
     came_from = self.request.params.get('came_from', referrer)
     message = ''
     login = ''
     password = ''
     if self.request.method == 'POST':
         login = self.request.POST['login']
         password = self.request.POST['password']
         valid_user = User.get(login, password)
         if valid_user:
             headers = remember(self.request, str(valid_user.id))
             User.log_login(str(valid_user.id))
             if valid_user.needs_pw_reset:
                 url = self.request.route_url('user_update')
                 return HTTPFound(location=url,
                                  headers=headers)
             return HTTPFound(location=came_from,
                              headers=headers)
         forget(self.request)
         message = 'Failed login'
     else:
         pass
     return {
         'request': self.request,
         'message': message,
     }
开发者ID:astromitts,项目名称:astrobase,代码行数:30,代码来源:views.py

示例10: sign_in_out

	def sign_in_out(self, request):
		username = request.POST.get('username')
		password = request.POST.get('password')
		if username:
			self.log.info("Login attempt: u = %s, pass = %s", username, password)
			if username in users and users[username] == password:
				self.log.info("Successful Login!")
				age = 60*60*24*32
				headers = pys.remember(request, username, max_age='%d' % age)

				reqPath = request.path.lstrip("/")

				reqPath = reqPath + ".mako"
				pgTemplate = self.lookupEngine.get_template(reqPath)
				pageContent = pgTemplate.render_unicode(request=request)
				return Response(body=pageContent, headers=headers)

			else:
				self.log.warn("Invalid user. Deleting cookie.")
				headers = pys.forget(request)
		else:
			self.log.warn("No user specified - Deleting cookie.")
			headers = pys.forget(request)

		return HTTPFound(location=request.route_url('login'))
开发者ID:GodOfConquest,项目名称:xA-Scraper,代码行数:25,代码来源:wsgi_server.py

示例11: logout

def logout(request):
    forget(request)
    referer = request.referer or '/'
    redirect_to = request.params.get('redirect', referer)
    if redirect_to == request.route_url('logout'):
        redirect_to = '/'
    raise httpexceptions.HTTPFound(location=redirect_to)
开发者ID:karenc,项目名称:cnx-authoring,代码行数:7,代码来源:views.py

示例12: anggaran_032

    def anggaran_032(self):
        ursKd = "0.00"
        prgKd = "00"
        kegKd = "32"
        params = self.request.params

        self.datas["mod"] = self.session["mod"]
        self.datas["kegiatanKd"] = "urusankd=%s&programkd=%s&kegiatankd=%s" %(ursKd, prgKd,kegKd)
        
        if self.logged and self.is_akses_mod('read'):
            self.datas['kegiatan'] = DBSession.query(KegiatanModel).\
                       join(ProgramModel).join(Urusan).filter(
                            Urusan.kode==ursKd,
                            ProgramModel.kode==prgKd,
                            KegiatanModel.kode==kegKd 
                            ).first()
            row = DBSession.query(KegiatanSubModel
                      ).filter(KegiatanSubModel.tahun_id == self.tahun,
                               KegiatanSubModel.unit_id == self.unit_id,
                               KegiatanSubModel.kegiatan_id==self.datas['kegiatan'].id
                               ).first()
            if row:
                self.datas['subkegiatan'] = row
                self.session["sub_keg_id"]=row.id
            else:
                self.datas['subkegiatan'] = ""
                self.session["sub_keg_id"]=0
            return dict(datas=self.datas)
        else:
            if not self.logged:
                headers=forget(self.request)
                return HTTPFound(location='/login?app=%s' % self.app, headers=headers)
            else:
                headers=forget(self.request)
                return HTTPFound(location='/anggaran', headers=headers)
开发者ID:aagusti,项目名称:osipkd-pdpt,代码行数:35,代码来源:anggaran.py

示例13: finish_password_change

def finish_password_change(request):
    localizer = request.localizer
    token = request.params.get('token')
    title = request.params.get('title')
    welcome = asbool(request.params.get('welcome'))
    discussion = discussion_from_request(request)
    if welcome:
        title = localizer.translate(_(
            'Welcome to {discussion_topic}.')).format(
            discussion_topic=discussion.topic if discussion else "Assembl")
    else:
        title = localizer.translate(_('Change your password'))

    user, validity = verify_password_change_token(token)
    logged_in = request.authenticated_userid  # if mismatch?
    if user and user.id != logged_in:
        # token for someone else: forget login.
        logged_in = None
        forget(request)
    token_date = get_data_token_time(token)
    old_token = (
        user is None or token_date is None or (
            user.last_login and token_date < user.last_login))

    if (validity != Validity.VALID or old_token) and not logged_in:
        # V-, V+P+W-B-L-: Invalid or obsolete token (obsolete+logged in treated later.)
        # Offer to send a new token
        if validity != Validity.VALID:
            error = localizer.translate(_(
                "This link is not valid. Do you want us to send another?"))
        else:
            error = localizer.translate(_(
                "This link has been used. Do you want us to send another?"))
        request.session.flash(error)
        return HTTPFound(location=maybe_contextual_route(
            request, 'request_password_change', _query=dict(
                user_id=user.id if user else '')))

    error = None
    p1, p2 = (request.params.get('password1', '').strip(),
              request.params.get('password2', '').strip())
    if p1 != p2:
        error = localizer.translate(_('The passwords are not identical'))
    elif p1:
        user.password_p = p1
        user.successful_login()
        headers = remember(request, user.id)
        request.response.headerlist.extend(headers)
        if discussion:
            maybe_auto_subscribe(user, discussion)
        request.session.flash(localizer.translate(_(
            "Password changed")), 'message')
        return HTTPFound(location=request.route_url(
            'home' if discussion else 'discussion_list',
            discussion_slug=discussion.slug))

    return dict(
        get_default_context(request),
        title=title, token=token, error=error)
开发者ID:assembl,项目名称:assembl,代码行数:59,代码来源:views.py

示例14: logout

def logout(request):
    """
    POST /api/logout
    :param request:
    :return:
    """
    forget(request)
    return {}
开发者ID:wangjun,项目名称:todolist,代码行数:8,代码来源:user.py

示例15: logout_view

def logout_view(request):
    logger.info('in logout view')
    user = authenticated_userid(request)
    if user is None:
        request.session.flash("need to be logged in to log out, lol")
    else:
        forget(request)
    return HTTPFound(location=request.route_url('playlists'))
开发者ID:AndrewCEmil,项目名称:slshr,代码行数:8,代码来源:tasks.py


注:本文中的pyramid.security.forget函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。