def save(self, targetname, yubikey_enabled, yubikey_prefix): person = People.by_username(turbogears.identity.current.user_name) target = People.by_username(targetname) if not can_edit_user(person, target): ff.error(_("You do not have permission to edit '%s'") % target.username) turbogears.redirect('/yubikey') return dict() new_configs = {'enabled': yubikey_enabled, 'prefix': yubikey_prefix} cur_configs = Configs.query.filter_by(person_id=target.id, application='yubikey').all() for config in cur_configs: for new_config in new_configs.keys(): if config.attribute == new_config: config.value = new_configs[new_config] del(new_configs[new_config]) for config in new_configs: c = Configs(application='yubikey', attribute=config, value=new_configs[config]) target.configs.append(c) mail_subject=_('Fedora Yubikey changed for %s' % target) mail_text=_(''' You have changed your Yubikey on your Fedora account %s. If you did not make this change, please contact [email protected]''' % target) email='*****@*****.**' % target send_mail(email, mail_subject, mail_text) turbogears.flash(_("Changes saved. Please allow up to 1 hour for changes to be realized.")) turbogears.redirect('/yubikey/') return dict()
def self_test(self, uid, otp): try: otp_verify(uid, otp) turbogears.flash(_("Yubikey auth success.")) except AuthException, error: ff.error(_("Yubikey auth Failed: %s." % error))