zoukankan      html  css  js  c++  java
  • 给已验证登录的用户添加访问限制

    @login_required
    def lockIndex(req):
             if not req.user.email.endswith('@example.com'):
                print req.path
                return redirect('/index')
             print 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
             print req.user.email
             print '-----------------request.user.is_authenticated()';
             print req.user.is_authenticated()
             if not req.user.is_authenticated():
                  return redirect('/index')
             print '-----------------request.user.is_authenticated()';
    
             print '---------lockIndex--------------'
             from django.conf import settings
             print req.user
             print settings.LOGIN_URL
             print '---------lockIndex--------------'
             return render_to_response('lockIndex.html')
    		 
    		 
    
    /lockIndex/
    [19/Sep/2018 12:20:44] "GET /lockIndex/ HTTP/1.1" 302 0
    [19/Sep/2018 12:20:44] "GET /index/ HTTP/1.1" 200 1190
    [19/Sep/2018 12:20:44] "GET /static/news/Css/Index/index.css HTTP/1.1" 304 0
    Not Found: /favicon.ico
    [19/Sep/2018 12:20:44] "GET /favicon.ico HTTP/1.1" 404 7449
    [19/Sep/2018 12:20:44] "GET /static/news/scan.jpg HTTP/1.1" 304 0
    [19/Sep/2018 12:20:44] "GET /static/news/login.jpg HTTP/1.1" 304 0
  • 相关阅读:
    http uri唯一标识
    http协议
    python模块 sys
    file 文件的操作
    库的介绍及使用
    python os模块
    python的序列化与反序列化
    python 字典的定义以及方法
    python字符串的常用方法
    在Windows下使用adb logcat grep
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348982.html
Copyright © 2011-2022 走看看