示例#1
0
def suspend(request):
    
    new_url = request.GET['url']
    attributes = get_manager(request)

    response = None
    
    if attributes:
        LOG.debug("Calling suspend with %s" % attributes.get_logout_url(new_url))
        response = shortcuts.redirect(attributes.get_logout_url(new_url))
        response = attributes.postproc_logout(response)
    
    else:
        response = shortcuts.redirect(new_url)

    response.set_cookie('pivot', request.user.id)
    return response
示例#2
0
def manage(request):

    myproviders = set()
    
    allmaps = UserMapping.objects.filter(registration__userid=request.user.id)
    for umap in allmaps:
        idx = umap.globaluser.find('@')
        if idx > 0:
            myproviders.add(umap.globaluser[idx+1:])

    ctx = dict()

    attributes = get_manager(request)
    if attributes:
        ctx['currpath'] = '%s/idmanager/idp_requests/suspend/' % attributes.root_url
    else:
        ctx['currpath'] = '/dashboard/idmanager/idp_requests/suspend/'
    
    ctx['idp_data_list'] = get_idp_list(myproviders)
    ctx['providers'] = myproviders
    
    return shortcuts.render(request, 'idmanager/idp_requests/idp_request.html', ctx)
示例#3
0
    def handle(self, request, data):

        user_is_editable = api.keystone.keystone_can_edit_user()
        if not user_is_editable:
            messages.error(request, _('Activating password is not supported.'))
            return False

        try:
            #api.keystone.user_update_own_password(request, None, data['new_password'])
            api.keystone.user_update_password(request, request.user.id, data['new_password'], False)
            
            if get_manager(request):
                return http.HttpResponseRedirect(reverse_lazy('login'))
            else:
                response = http.HttpResponseRedirect(reverse_lazy('logout'))
                msg = _("Password changed. Please log in again to continue.")
                utils.add_logout_reason(request, response, msg)
                return response
                
        except Exception:
            exceptions.handle(request, _('Unable to activate password.'))

        return False
示例#4
0
def resume(request):

    userid = request.COOKIES['pivot']

    attributes = get_manager(request)
    
    response = None
    
    if attributes:
    
        try:
            with transaction.atomic():
        
                extId = attributes.username
        
                registr = Registration.objects.filter(userid=userid)[0]
                u_map = UserMapping(globaluser=extId, registration=registr)
                u_map.save(force_insert=True)

            LOG.debug('Calling resume with %s/idmanager' % attributes.root_url)
            response = shortcuts.redirect(attributes.root_url + '/idmanager')
        
        except IntegrityError:
            LOG.error("Duplicate map for %s in %s" % (userid, extId))
            response = shortcuts.redirect(reverse('logout'))
            response.set_cookie('logout_reason', _("An account already uses the selected identity"))
        except:
            LOG.error("Cannot map userid %s" % userid, exc_info=True)
            response = shortcuts.redirect(reverse('logout'))
            err_msg = "A failure occurs authenticating user\nPlease, contact the cloud managers"
            response.set_cookie('logout_reason', err_msg)

    else:
        response = shortcuts.redirect('/dashboard')

    response.delete_cookie('pivot')
    return response
示例#5
0
    def handle(self, request, data):

        user_is_editable = api.keystone.keystone_can_edit_user()
        if not user_is_editable:
            messages.error(request, _('Activating password is not supported.'))
            return False

        try:
            #api.keystone.user_update_own_password(request, None, data['new_password'])
            api.keystone.user_update_password(request, request.user.id,
                                              data['new_password'], False)

            if get_manager(request):
                return http.HttpResponseRedirect(reverse_lazy('login'))
            else:
                response = http.HttpResponseRedirect(reverse_lazy('logout'))
                msg = _("Password changed. Please log in again to continue.")
                utils.add_logout_reason(request, response, msg)
                return response

        except Exception:
            exceptions.handle(request, _('Unable to activate password.'))

        return False
示例#6
0
def enableActPwd(obj, context):
    request = context['request']
    if get_manager(request):
        return True
    return False
示例#7
0
def enableActPwd(obj, context):
    request = context['request']
    if get_manager(request):
        return True
    return False