Ejemplo n.º 1
0
class RemovePASProvidersSchema(colander.Schema):
    currently_attached = colander.SchemaNode(
        colander.Set(),
        title=_("Currently active"),
        description=_(
            "remove_pas_description",
            default="Check any you wish to remove from your account. "
            "You won't be able to login with them again."),
        widget=currently_attached_widget)
Ejemplo n.º 2
0
def confirm_pas_attach_title(node, kw):
    view = kw['view']
    request = kw['request']
    msg = _("confirm_attach_pas_title",
            default = "You're logged in as '${userid}' - do you wish to be able to login with your current account using ${title}?",
            mapping = {'userid': request.authenticated_userid, 'title': request.localizer.translate(view.method.title)})
    return msg
Ejemplo n.º 3
0
def render_login_button(context, request, va, **kw):
    google_login_js.need()
    response = {}
    response['CLIENT_ID'] = "XXX"  #FIXME: Fetch from some smart place
    response['error_msg'] = _("Error while signing in with Google:")
    return render('arche_pas_social:templates/google.pt',
                  response,
                  request=request)
Ejemplo n.º 4
0
 def save_success(self, appstruct):
     self.flash_messages.add(self.default_success, type="success")
     mapper = IProviderMapper(self.context)
     mapper.add(self.request.authenticated_userid, self.method.name, self.identifier)
     msg = _("attachment_notice",
             default = "From now on you may login with ${method_name}.",
             mapping = {'method_name': self.request.localizer.translate(self.method.title)})
     self.flash_messages.add(msg)
     return self.relocate_response(self.request.resource_url(self.context))
Ejemplo n.º 5
0
def confirm_pas_attach_title(node, kw):
    view = kw['view']
    request = kw['request']
    msg = _(
        "confirm_attach_pas_title",
        default=
        "You're logged in as '${userid}' - do you wish to be able to login with your current account using ${title}?",
        mapping={
            'userid': request.authenticated_userid,
            'title': request.localizer.translate(view.method.title)
        })
    return msg
Ejemplo n.º 6
0
 def save_success(self, appstruct):
     self.flash_messages.add(self.default_success, type="success")
     mapper = IProviderMapper(self.context)
     mapper.add(self.request.authenticated_userid, self.method.name,
                self.identifier)
     msg = _("attachment_notice",
             default="From now on you may login with ${method_name}.",
             mapping={
                 'method_name':
                 self.request.localizer.translate(self.method.title)
             })
     self.flash_messages.add(msg)
     return self.relocate_response(self.request.resource_url(self.context))
Ejemplo n.º 7
0
class RemovePASProvidersForm(BaseForm):

    title = _("Remove providers?")

    @property
    def buttons(self):
        return (self.button_delete, self.button_cancel)

    def get_schema(self):
        return RemovePASProvidersSchema()

    def delete_success(self, appstruct):
        print appstruct
        return self.relocate_response(self.request.resource_url(self.context))
Ejemplo n.º 8
0
 def register_success(self, appstruct):
     self.flash_messages.add(_("Welcome, you're now registered!"), type="success")
     factory = self.get_content_factory('User')
     userid = appstruct.pop('userid')
     #FIXME: What decide if email is validated or not here? Google has a setting for validated email for instance
     #if not self.root.skip_email_validation:
     #    appstruct['email_validated'] = True
     appstruct.pop('__pas_identifier__', None)
     appstruct.pop('__pas_provider__', None)
     mapper = IProviderMapper(self.context)
     mapper.add(userid, self.method.name, self.identifier)
     obj = factory(**appstruct)
     self.context['users'][userid] = obj
     headers = remember(self.request, obj.userid)
     return self.relocate_response(self.request.resource_url(self.root), headers = headers)
Ejemplo n.º 9
0
class PASPortlet(PortletType):
    name = u"pas_social_portlet"
    title = _(u"Social auth")

    def render(self, context, request, view, **kwargs):
        try:
            contents = render_view_group(request.root, request, 'arche_pas_social', as_type = 'generator')
        except ComponentLookupError:
            logger.warn("Can't render PASPortlet - arche_pas_social is empty.")
            return
        return render("arche_pas_social:templates/portlet.pt",
                      {'title': self.title,
                       'portlet': self.portlet,
                       'contents': contents},
                      request = request)
Ejemplo n.º 10
0
 def register_success(self, appstruct):
     self.flash_messages.add(_("Welcome, you're now registered!"),
                             type="success")
     factory = self.get_content_factory('User')
     userid = appstruct.pop('userid')
     #FIXME: What decide if email is validated or not here? Google has a setting for validated email for instance
     #if not self.root.skip_email_validation:
     #    appstruct['email_validated'] = True
     appstruct.pop('__pas_identifier__', None)
     appstruct.pop('__pas_provider__', None)
     mapper = IProviderMapper(self.context)
     mapper.add(userid, self.method.name, self.identifier)
     obj = factory(**appstruct)
     self.context['users'][userid] = obj
     headers = remember(self.request, obj.userid)
     return self.relocate_response(self.request.resource_url(self.root),
                                   headers=headers)
Ejemplo n.º 11
0
class GoogleAuth(SocialAuth):
    name = 'google'
    title = _("Google")

    def get_identifier(self, data):
        if data:
            return data.get('id', None)

    def get_data(self, request):
        access_token = request.POST.get('access_token', None)
        response = requests.get(
            'https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' %
            access_token)
        if response.ok:
            return response.json()

    def get_appstruct(self, data):
        appstruct = {}
        appstruct['email'] = data.get('email', '')
        appstruct['first_name'] = data.get('given_name', '')
        appstruct['last_name'] = data.get('family_name', '')
        return appstruct
Ejemplo n.º 12
0
 def __call__(self, node, value):
     if value != True:
         raise colander.Invalid(node, _("You must confirm to use this."))
Ejemplo n.º 13
0
def render_login_button(context, request, va, **kw):
    google_login_js.need()
    response = {}
    response['CLIENT_ID'] = "XXX" #FIXME: Fetch from some smart place
    response['error_msg'] = _("Error while signing in with Google:")
    return render('arche_pas_social:templates/google.pt', response, request = request)
Ejemplo n.º 14
0
 def __call__(self, node, value):
     if value != True:
         raise colander.Invalid(node, _("You must confirm to use this."))