• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python security.forget函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: finish_password_change

def finish_password_change(request):
    localizer = request.localizer
    token = request.params.get('token')
    title = request.params.get('title')
    user, validity = verify_password_change_token(token)
    logged_in = authenticated_userid(request)  # 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?"))

        return HTTPFound(location=maybe_contextual_route(
            request, 'request_password_change', _query=dict(
                user_id=user.id if user else '',
                error=error)))

    discussion_slug = request.matchdict.get('discussion_slug', None)
    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.last_login = datetime.utcnow()
        headers = remember(request, user.id)
        request.response.headerlist.extend(headers)
        if discussion_slug:
            discussion = discussion_from_request(request)
            maybe_auto_subscribe(user, discussion)
        return HTTPFound(location=request.route_url(
            'home' if discussion_slug else 'discussion_list',
            discussion_slug=discussion_slug,
            _query=dict(
                message=localizer.translate(_(
                    "Password changed")))))

    slug_prefix = "/" + discussion_slug if discussion_slug else ""
    return dict(
        get_default_context(request),
        title=title, slug_prefix=slug_prefix, token=token, error=error)
开发者ID:festrade,项目名称:assembl,代码行数:55,代码来源:views.py


示例17: sign_in_out

def sign_in_out(request):
    username = request.POST.get('username')
    if username:
        user = UserService.by_name(username, request=request)
        if user and user.verify_password(request.POST.get('password')):
            headers = remember(request, user.name)
        else:
            headers = forget(request)
    else:
        headers = forget(request)
    return HTTPFound(location=request.route_url('home'), headers=headers)
开发者ID:antleocar,项目名称:blog,代码行数:11,代码来源:default.py


示例18: anggaran_022

 def anggaran_022(self):
     params = self.request.params
     if self.logged and self.is_akses_mod('read'):
         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,代码行数:11,代码来源:anggaran.py


示例19: get_non_expired_user_id

def get_non_expired_user_id(request):
    user_id = request.authenticated_userid
    discussion = discussion_from_request(request)
    if user_id:
        user = User.get(user_id)
        if user.login_expired(discussion):
            forget(request)
            localizer = request.localizer
            request.session.flash(localizer.translate(_(
                "Your session has expired, you need to login again")))
            user_id = None
    return user_id
开发者ID:assembl,项目名称:assembl,代码行数:12,代码来源:util.py


示例20: assembl_login_complete_view

def assembl_login_complete_view(request):
    """
    This backend view handles login form submissions received from both v1 and v2 frontend views.
    Check if proper authorization. Otherwise send to another page.
    """
    session = AgentProfile.default_db
    # POST before GET
    identifier = (request.POST.get('identifier').strip() or
                  request.GET.get('identifier').strip() or '')
    password = request.params.get('password', '').strip()
    referrer = request.POST.get('referrer', None)
    is_v2 = True if referrer == 'v2' else False
    next_view = handle_next_view(request, True)
    logged_in = request.authenticated_userid
    localizer = request.localizer
    user = None
    user, account = from_identifier(identifier)
    query = {"identifier": identifier,
             "next": next_view} if identifier else {"next": next_view}
    if not user:
        error_message = localizer.translate(_("This user cannot be found"))
        request.session.flash(error_message)
        route_name = 'react_login' if is_v2 else 'login'
        return HTTPFound(location=maybe_contextual_route(
            request, route_name,
            _query=query))
    if account and not account.verified:
        return HTTPFound(location=maybe_contextual_route(
            request, 'confirm_emailid_sent', email_account_id=account.id))
    if logged_in:
        if user.id != logged_in:
            # logging in as a different user
            # Could I be combining account?
            forget(request)
        else:
            # re-logging in? Why?
            return HTTPFound(location=next_view)
    if not user.check_password(password):
        error_message = localizer.translate(_("Invalid user and password"))
        user.login_failures += 1
        # TODO: handle high failure count
        request.session.flash(error_message)
        route_name = 'react_login' if is_v2 else 'login'
        return HTTPFound(location=maybe_contextual_route(
            request, route_name,
            _query=query))
    user.successful_login()
    headers = remember(request, user.id)
    request.response.headerlist.extend(headers)
    discussion = discussion_from_request(request)
    if discussion:
        maybe_auto_subscribe(user, discussion)
    return HTTPFound(location=next_view)
开发者ID:assembl,项目名称:assembl,代码行数:53,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python security.has_permission函数代码示例发布时间:2022-05-27
下一篇:
Python security.effective_principals函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap