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


Python auth.Auth类代码示例

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


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

示例1: do_registrar

def do_registrar():
    """
    """
    _auth = Auth()
    if not _auth.is_login:
        errors = [] #errores 
        #validacion de campos vacios
        _username = request.forms.get('username')
        if _username == "":
            errors.append("El campo Usuario esta vacio")

        #validacion de contrasenias
        _password = request.forms.get('password')
        repassword = request.forms.get('repassword')
        if len(_password) < 8 or len(_password) >= 16:
            errors.append("la contrasenia debe tener entre 8 y 16 caracteres")
        if _password != repassword:
            errors.append("Las contrasenias no coinciden")

        _name = request.forms.get('name')
        if _name == "":
            errors.append("El campo Nombre esta vacio")
        
        _email = request.forms.get('email')
        if _email == "":
            errors.append("El campo Email esta vacio")

        if len(errors) == 0:
            #validacion de que no exista el usuario
            query = db.GqlQuery("SELECT * FROM User WHERE username = :1", _username)        
            if query.count() != 0:
                errors.append("El nombre de usuarios \"%s\" ya existe" %_username)
                form_error = True

            else:            
                user = User(
                    username = _username,
                    password = _password,
                    name = _name,
                    email = _email,
                )
                user.put()
                return template("auth/registrar-ok.html")

        else:
            form_error = True
        #si llego hasta aqui hay algun tipo de errors        
        data = {
            "errors" : errors,
            "form_error": form_error,
            "username": _username,
            "name": _name,
            "email": _email,
        }
        return template("auth/registrar.html", data)

    else:
        message = "Error ya has iniciado Session con la cuenta \"%s\" " %_auth.is_login()
        message += "en caso de querer proceder por fabor cierra la session actual."
        return template("message.html", {'message': message} )
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:60,代码来源:auth_views.py

示例2: index

def index():
    #pagina de inicio
    _auth = Auth() 
    if (_auth.is_login()):
        is_login = True
    else:
        is_login = False
    return template('home.html', {'is_login':is_login })
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:8,代码来源:views.py

示例3: listado

def listado():
    _auth = Auth()
    if _auth.is_login():
        data = {}
        user = db.GqlQuery("SELECT * FROM User WHERE username = :1", _auth.is_login()).fetch(1)[0]
        data['series'] = Serie.all().filter("user=",user)
        return template("series/listado.html", data)
    else:
        return template("sin-permisos.html")
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:9,代码来源:series_views.py

示例4: login

def login():
    """
        Iniciar Session
    """
    _auth = Auth()
    if not _auth.is_login():
        return template('auth/login.html')
    else:
        message = "Error ya has iniciado Session con la cuenta \"%s\" " %_auth.is_login()
        message += "en caso de querer proceder por fabor cierra la session actual."
        return template("message.html", {'message': message} )
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:11,代码来源:auth_views.py

示例5: do_login

def do_login():
    """
        Captura los datos de la vista para iniciar session
    """
    _auth = Auth()
    usr = request.forms.get('username')
    pwd = request.forms.get('password')

    if _auth.login(usr, pwd):
        redirect('/')
    else:
        return template('auth/login.html', {"login_error": True})
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:12,代码来源:auth_views.py

示例6: do_registrar

def do_registrar():
    _auth = Auth()
    if _auth.is_login():
        #field validation
        _name = request.forms.get('name')
        _day = request.forms.get('day')
        _url = request.forms.get('url')
        _chapter_url = request.forms.get('chapter_url')
        _num_chapters = request.forms.get('mun_chapters')
        _old_chapter = request.forms.get('old_chapter')

        #el usuario existe se supone que esta logueado sino cagada jaaj
        _user = db.GqlQuery("SELECT * FROM User WHERE username = :1", _auth.is_login()).fetch(1)[0]
        
        if _num_chapters <= _old_chapter:
            _old_chapter = _num_chapters
            _enabled = False
        else:
            _enabled = True

        serie = Serie(
            user = _user,
            name = _name,
            day = _day,
            url = _url,
            chapter_url = _chapter_url,
            num_chapters = int(_num_chapters),
            old_chapter = int(_old_chapter), #ultimo capitulo que salio    
            enabled = _enabled
        )
        serie.put()
       
        # Registro los capitulos
        n = int(_old_chapter) + 1
        for num in range(1, n):
            chapter = Chapter(
                serie = serie,
                number = num,
                url = serie.chapter_url %num,
                show = False
            )
            chapter.put()

        return "Serie Registrada"

        #return template("series/registrar.html")
    else:
        return template("sin-permisos.html")
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:48,代码来源:series_views.py

示例7: wrapped

        def wrapped(*args, **kwargs):
            response = None
            kwargs['project'], kwargs['node'] = _kwargs_to_nodes(kwargs)
            node = kwargs['node'] or kwargs['project']

            kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)
            user = kwargs['auth'].user

            if 'api_node' in kwargs:
                api_node = kwargs['api_node']
            else:
                api_node = get_api_key()
                kwargs['api_node'] = api_node

            key = request.args.get('view_only', '').strip('/')
            #if not login user check if the key is valid or the other privilege

            kwargs['auth'].private_key = key
            if not node.is_public or not include_public:
                if key not in node.private_link_keys_active:
                    if not check_can_access(node=node, user=user,
                            api_node=api_node, key=key):
                        url = '/login/?next={0}'.format(request.path)
                        redirect_url = check_key_expired(key=key, node=node, url=url)
                        response = redirect(redirect_url)

            return response or func(*args, **kwargs)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:27,代码来源:decorators.py

示例8: wrapped

        def wrapped(*args, **kwargs):
            response = None
            _inject_nodes(kwargs)
            node = kwargs['node']

            kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)
            user = kwargs['auth'].user

            key = request.args.get('view_only', '').strip('/')
            #if not login user check if the key is valid or the other privilege

            kwargs['auth'].private_key = key
            link_anon = None
            if not include_view_only_anon:
                from website.models import PrivateLink
                try:
                    link_anon = PrivateLink.find_one(Q('key', 'eq', key)).anonymous
                except ModularOdmException:
                    pass

            if not node.is_public or not include_public:
                if not include_view_only_anon and link_anon:
                    if not check_can_access(node=node, user=user):
                        raise HTTPError(http.UNAUTHORIZED)
                elif key not in node.private_link_keys_active:
                    if not check_can_access(node=node, user=user, key=key):
                        redirect_url = check_key_expired(key=key, node=node, url=request.url)
                        if request.headers.get('Content-Type') == 'application/json':
                            raise HTTPError(http.UNAUTHORIZED)
                        else:
                            response = redirect(cas.get_login_url(redirect_url))

            return response or func(*args, **kwargs)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:33,代码来源:decorators.py

示例9: test_from_kwargs

 def test_from_kwargs(self):
     user = UserFactory()
     request_args = {'view_only': 'mykey'}
     kwargs = {'user': user}
     auth_obj = Auth.from_kwargs(request_args, kwargs)
     assert_equal(auth_obj.user, user)
     assert_equal(auth_obj.private_key, request_args['view_only'])
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:7,代码来源:test_auth.py

示例10: wrapped

        def wrapped(*args, **kwargs):
            _inject_nodes(kwargs)

            kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)

            response = check_contributor_auth(kwargs['node'], kwargs['auth'], include_public, include_view_only_anon)

            return response or func(*args, **kwargs)
开发者ID:icereval,项目名称:osf.io,代码行数:8,代码来源:decorators.py

示例11: wrapped

        def wrapped(*args, **kwargs):
            response = None
            target = None
            guid = Guid.load(kwargs.get('guid'))
            if guid:
                target = getattr(guid, 'referent', None)
            else:
                _inject_nodes(kwargs)

            target = target or kwargs.get('node')

            kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)

            response = check_contributor_auth(target, kwargs['auth'], include_public, include_view_only_anon)

            return response or func(*args, **kwargs)
开发者ID:erinspace,项目名称:osf.io,代码行数:16,代码来源:decorators.py

示例12: wrapped

        def wrapped(*args, **kwargs):
            # Ensure `project` and `node` kwargs
            _inject_nodes(kwargs)
            node = kwargs["node"]

            kwargs["auth"] = Auth.from_kwargs(request.args.to_dict(), kwargs)
            user = kwargs["auth"].user

            # User must be logged in
            if user is None:
                raise HTTPError(http.UNAUTHORIZED)

            # User must have permissions
            if not node.has_permission(user, permission):
                raise HTTPError(http.FORBIDDEN)

            # Call view function
            return func(*args, **kwargs)
开发者ID:keyz182,项目名称:osf.io,代码行数:18,代码来源:decorators.py

示例13: wrapped

        def wrapped(*args, **kwargs):
            response = None
            _inject_nodes(kwargs)
            node = kwargs['node']

            kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)
            user = kwargs['auth'].user

            key = request.args.get('view_only', '').strip('/')
            #if not login user check if the key is valid or the other privilege

            kwargs['auth'].private_key = key
            if not node.is_public or not include_public:
                if key not in node.private_link_keys_active:
                    if not check_can_access(node=node, user=user, key=key):
                        redirect_url = check_key_expired(key=key, node=node, url=request.url)
                        response = redirect(cas.get_login_url(redirect_url))

            return response or func(*args, **kwargs)
开发者ID:PatrickEGorman,项目名称:osf.io,代码行数:19,代码来源:decorators.py

示例14: _view_registries_landing_page

def _view_registries_landing_page(campaign=None, **kwargs):
    """Landing page for the various registrations"""
    auth = kwargs['auth'] = Auth.from_kwargs(request.args.to_dict(), kwargs)
    is_logged_in = kwargs['auth'].logged_in
    if is_logged_in:
        registerable_nodes = [
            node for node
            in auth.user.contributor_to
            if node.has_permission(user=auth.user, permission='admin')
        ]
        has_projects = bool(registerable_nodes)
    else:
        has_projects = False

    return {
        'is_logged_in': is_logged_in,
        'has_draft_registrations': bool(utils.drafts_for_user(auth.user, campaign)),
        'has_projects': has_projects,
        'campaign_long': utils.REG_CAMPAIGNS.get(campaign),
        'campaign_short': campaign

    }
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:22,代码来源:views.py

示例15: registrar

def registrar():
    _auth = Auth()
    if _auth.is_login():
        return template("series/registrar.html")
    else:
        return template("sin-permisos.html")
开发者ID:l2radamanthys,项目名称:mis-series,代码行数:6,代码来源:series_views.py


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