Пример #1
0
 def _change_admin_password(self, row):
     area = row['name'].value()
     if not area:
         return
     db_key = pytis.extensions.dbfunction('pytis_crypto_db_key',
                                          ('key_name_', pytis.data.sval('pytis'),))
     import config
     connection_data = config.dbconnection
     key_id, key = pytis.extensions.crypto_admin_key(area, 'admin', connection_data)
     if not key_id or not key:
         pytis.form.run_dialog(pytis.form.Error,
                               _(u"Nebyl nalezen klíč administrátora pro tuto oblast"))
         return
     row = pytis.form.new_record("crypto.NewAdminPasswd", multi_insert=False)
     if not row:
         return
     old_password = row["old_password"].value()
     if not pytis.extensions.check_crypto_password(key, old_password, connection_data):
         pytis.form.run_dialog(pytis.form.Error, _(u"Chybné heslo"))
     encrypted_old_password = rsa_encrypt(db_key, old_password)
     new_password = row["new_password"].value()
     encrypted_new_password = rsa_encrypt(db_key, new_password)
     function = pytis.data.DBFunctionDefault('pytis_crypto_change_password', connection_data)
     row = pytis.data.Row((('id_', key_id,),
                           ('old_psw', pytis.data.sval(encrypted_old_password),),
                           ('new_psw', pytis.data.sval(encrypted_new_password),),))
     if not function.call(row)[0][0].value():
         pytis.form.run_dialog(pytis.form.Error, _(u"Heslo se změnit nepodařilo"))
         return
     pytis.form.run_dialog(pytis.form.Message, _(u"Heslo bylo změněno"))
Пример #2
0
    def update_login_data(self, user, password):
        """Set given login parameters in the instance.

        Arguments:

          user -- database user as a string or 'None'
          password -- database password as a string or 'None'

        """
        self._user = user
        self._password = password
        import pytis.extensions
        # If `password' is wrong then the following dbfunction call will
        # initiate new password dialog and will invoke this method recursively.
        # In such a case we must not set the wrong password here.
        self._crypto_password = None
        db_key = pytis.extensions.dbfunction('pytis_crypto_db_key',
                                             ('key_name_', pytis.data.sval('pytis'),))
        if self._crypto_password is None and db_key:
            self._crypto_password = rsa_encrypt(db_key, password)
Пример #3
0
    def update_login_data(self, user, password):
        """Set given login parameters in the instance.

        Arguments:

          user -- database user as a string or 'None'
          password -- database password as a string or 'None'

        """
        self._user = user
        self._password = password
        import pytis.extensions
        # If `password' is wrong then the following dbfunction call will
        # initiate new password dialog and will invoke this method recursively.
        # In such a case we must not set the wrong password here.
        self._crypto_password = None
        if self._db_key is None:
            from pytis.dbdefs.db_pytis_crypto import PytisCryptoDbKey
            self._db_key = pytis.data.dbfunction(PytisCryptoDbKey, 'pytis')
        if self._crypto_password is None and self._db_key:
            self._crypto_password = rsa_encrypt(self._db_key, password)