Пример #1
0
    def dispatch(self, request, *args, **kwargs):
        # Load credentials from the request
        self.application_credentials = self.load_credentials(request)

        if not self.application_credentials['application_id']:
            # if no client_id was found, notify and progress no further
            messages.error(
                request, 'OUATH2 ERROR: client_id is missing in query_string')
            context = {
                'next': (reverse('fiware_oauth2_authorize') + '?' +
                         self.request.GET.urlencode()),
                'redirect_field_name':
                auth.REDIRECT_FIELD_NAME,
            }
            return auth_views.login(
                request,
                extra_context=context,
                form_class=fiware_auth_forms.LoginWithEmailForm,
                **kwargs)

        # Get the application details
        try:
            self.application = fiware_api.keystone.application_get(
                request,
                self.application_credentials['application_id'],
                use_idm_account=True)

        except Exception:
            msg = ('Unable to retrieve application.')
            LOG.exception(msg)
            messages.error(request, (msg))
            return redirect('horizon:user_home')

        if request.user.is_authenticated():
            # continue
            return super(AuthorizeView, self).dispatch(request, *args,
                                                       **kwargs)
        else:
            # redirect to the login page showing some info about the application
            self.application.avatar = idm_utils.get_avatar(
                self.application, 'img_medium',
                idm_utils.DEFAULT_APP_MEDIUM_AVATAR)
            context = {
                'next': (reverse('fiware_oauth2_authorize') + '?' +
                         self.request.GET.urlencode()),
                'redirect_field_name':
                auth.REDIRECT_FIELD_NAME,
                'show_application_details':
                True,
                'application':
                self.application,
            }

            LOG.debug('OAUTH2: Login page with consumer details')

            return auth_views.login(
                request,
                extra_context=context,
                form_class=fiware_auth_forms.LoginWithEmailForm,
                **kwargs)
Пример #2
0
    def dispatch(self, request, *args, **kwargs):
        # Load credentials from the request
        self.application_credentials = self.load_credentials(request)

        if not self.application_credentials['application_id']:
            # if no client_id was found, notify and progress no further
            messages.error(request, 'OUATH2 ERROR: client_id is missing in query_string')
            context = {
                'next':(reverse('fiware_oauth2_authorize') + '?' 
                    + self.request.GET.urlencode()),
                'redirect_field_name': auth.REDIRECT_FIELD_NAME,
            }
            return auth_views.login(
                request, 
                extra_context=context,
                form_class=fiware_auth_forms.LoginWithEmailForm, 
                **kwargs)

        # Get the application details
        try:
            self.application = fiware_api.keystone.application_get(
                request,
                self.application_credentials['application_id'],
                use_idm_account=True)

        except Exception:
            msg = ('Unable to retrieve application.')
            LOG.exception(msg)
            messages.error(request, (msg))
            return redirect('horizon:user_home')

        if request.user.is_authenticated():
            # continue
            return super(AuthorizeView, self).dispatch(request, *args, **kwargs)
        else:
            # redirect to the login page showing some info about the application
            self.application.avatar = idm_utils.get_avatar(
                self.application, 
                'img_medium', idm_utils.DEFAULT_APP_MEDIUM_AVATAR)
            context = {
                'next':(reverse('fiware_oauth2_authorize') + '?' 
                    + self.request.GET.urlencode()),
                'redirect_field_name': auth.REDIRECT_FIELD_NAME,
                'show_application_details':True,
                'application':self.application,
            }

            LOG.debug('OAUTH2: Login page with consumer details')

            return auth_views.login(
                request, 
                extra_context=context,
                form_class=fiware_auth_forms.LoginWithEmailForm, 
                **kwargs)
Пример #3
0
def splash(request):
    if request.user.is_authenticated():
        return shortcuts.redirect(get_user_home(request.user))
    form = login(request)
    request.session.clear()
    request.session.set_test_cookie()
    return shortcuts.render(request, 'splash.html', {'form': form})
Пример #4
0
def splash(request):
    if request.user.is_authenticated():
        #license_status = api.vsm.license_get(request)[1]
        #if license_status is None or\
        #    license_status.get('license_accept', False) == False:
        #        return license_gate(request)
        #else:
        return shortcuts.redirect(get_user_home(request.user))
    form = login(request)
    request.session.clear()
    request.session.set_test_cookie()
    return shortcuts.render(request, 'splash.html', {'form': form})
Пример #5
0
def splash(request):
    if request.user.is_authenticated():
        #license_status = api.vsm.license_get(request)[1]
        #if license_status is None or\
        #    license_status.get('license_accept', False) == False:
        #        return license_gate(request)
        #else:
        return shortcuts.redirect(get_user_home(request.user))
    form = login(request)
    request.session.clear()
    request.session.set_test_cookie()
    return shortcuts.render(request, 'splash.html', {'form': form})