Example #1
0
 def tokenValue(self):
     """Token value for UI
     """
     token = self.tokenForThisUser()
     if token is None:
         token = _(u'invalid_token', default=u"Invalid token")
     return token
Example #2
0
 def tokenValue(self):
     """Token value for UI
     """
     token = self.tokenForThisUser()
     if token is None:
         token = _(u'invalid_token', default=u"Invalid token")
     return token
Example #3
0
    def resetToken(self):
        """Reset the user's token
        """
        if self.isUserAnonymous():
            return

        portal_state = getMultiAdapter((self.context, self.request), name=u'plone_portal_state')
        user_id = portal_state.member().getId()
        token_mgr = getUtility(ITokenManager)
        new_token = token_mgr.resetToken(user_id)
        core_cs = self.getCommandSet('core')
        core_cs.setAttribute('#aws-authrss-token-value', 'value', new_token)
        plone_cs = self.getCommandSet('plone')
        plone_cs.issuePortalMessage(
            _(u'msg_token_changed',
              default=u"Your RSS token has been changed")
              )
        return
Example #4
0
 def purgeTokens(self):
     """Remove the tokens of unknown or gone users
     """
     pruned = 0
     plone_tools = getMultiAdapter((self.context, self.request), name=u'plone_tools')
     mtool = plone_tools.membership()
     token_mgr = getUtility(ITokenManager)
     for user_id in token_mgr.knownUserIds():
         if mtool.getMemberById(user_id) is None:
             token_mgr.pruneUserId(user_id)
             pruned += 1
     plone_cs= self.getCommandSet('plone')
     message = _(
         u'msg_pruned_users',
         default=u"${pruned} unknown user(s) have been removed from RSS tokens registry",
         mapping={u'pruned': str(pruned)}
         )
     plone_cs.issuePortalMessage(message)
     return
Example #5
0
    def resetToken(self):
        """Reset the user's token
        """
        if self.isUserAnonymous():
            return

        portal_state = getMultiAdapter((self.context, self.request),
                                       name=u'plone_portal_state')
        user_id = portal_state.member().getId()
        token_mgr = getUtility(ITokenManager)
        new_token = token_mgr.resetToken(user_id)
        return json.dumps({
            'success':
            True,
            'message':
            translate(_(u'msg_token_changed',
                        default=u"Your RSS token has been changed"),
                      context=self.request),
            'token':
            new_token
        })
Example #6
0
    def purgeTokens(self):
        """Remove the tokens of unknown or gone users
        """
        pruned = 0
        plone_tools = getMultiAdapter((self.context, self.request),
                                      name=u'plone_tools')
        mtool = plone_tools.membership()
        token_mgr = getUtility(ITokenManager)
        for user_id in token_mgr.knownUserIds():
            if mtool.getMemberById(user_id) is None:
                token_mgr.pruneUserId(user_id)
                pruned += 1

        message = _(
            u'msg_pruned_users',
            default=
            u"${pruned} unknown user(s) have been removed from RSS tokens registry",
            mapping={u'pruned': str(pruned)})
        return json.dumps({
            'success': True,
            'message': translate(message, context=self.request),
        })