Exemplo n.º 1
0
    def _create_user_and_login(self, persistent_id, username, email=None,
                               display_name=None, locale=None):
        user = User.create(username,
                           email,
                           locale=locale,
                           display_name=display_name,
                           shibboleth_persistent_id=persistent_id)
        # NOTE: We might want to automatically join the current instance
        # here at some point

        meta.Session.commit()
        return self._login(user, h.user.post_register_url(user))
Exemplo n.º 2
0
    def _create_user_and_login(self,
                               persistent_id,
                               username,
                               email=None,
                               display_name=None,
                               locale=None):
        user = User.create(username,
                           email,
                           locale=locale,
                           display_name=display_name,
                           shibboleth_persistent_id=persistent_id)
        # NOTE: We might want to automatically join the current instance
        # here at some point

        meta.Session.commit()
        return self._login(user, h.user.post_register_url(user))
Exemplo n.º 3
0
    def _register(self, persistent_id):

        if request.method == 'GET':

            defaults = {
                'email': request.headers.get('shib-email'),
            }
            return self._register_form(defaults=defaults)

        # POST
        check_csrf()

        try:
            form_result = ShibbolethRegisterForm().to_python(request.params)

            if config.get_bool('adhocracy.force_randomized_user_names'):
                username = None
            else:
                username = form_result['username']
            if config.get_bool('adhocracy.set_display_name_on_register'):
                display_name = form_result['display_name']
            else:
                display_name = None
            user = User.create(username,
                               form_result['email'],
                               display_name=display_name,
                               shibboleth_persistent_id=persistent_id)

            # NOTE: We might want to automatically join the current instance
            # here at some point

            meta.Session.commit()

            return self._login(user, h.user.post_register_url(user))

        except formencode.Invalid, i:
            return self._register_form(errors=i.unpack_errors())