You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.8 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Laurent Mignon
  5. # Copyright 2014 'ACSONE SA/NV'
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. from openerp.osv import orm, fields
  22. from openerp.tools.safe_eval import safe_eval
  23. import types
  24. class auth_from_http_remote_user_configuration(orm.TransientModel):
  25. _name = 'auth_from_http_remote_user.config.settings'
  26. _inherit = 'res.config.settings'
  27. _columns = {
  28. 'default_login_page_disabled': fields.boolean("Disable login page",
  29. help="""
  30. Disable the default login page.
  31. If the HTTP_REMOTE_HEADER field is not found or no user matches the given one,
  32. the system will display a login error page if the login page is disabled.
  33. Otherwise the normal login page will be displayed.
  34. """),
  35. }
  36. def is_default_login_page_disabled(self, cr, uid, fields, context=None):
  37. ir_config_obj = self.pool['ir.config_parameter']
  38. default_login_page_disabled = ir_config_obj.get_param(cr,
  39. uid,
  40. 'auth_from_http_remote_user.default_login_page_disabled')
  41. if isinstance(default_login_page_disabled, types.BooleanType):
  42. return default_login_page_disabled
  43. return safe_eval(default_login_page_disabled)
  44. def get_default_default_login_page_disabled(self, cr, uid, fields, context=None):
  45. default_login_page_disabled = self.is_default_login_page_disabled(cr, uid, fields, context)
  46. return {'default_login_page_disabled': default_login_page_disabled}
  47. def set_default_default_login_page_disabled(self, cr, uid, ids, context=None):
  48. config = self.browse(cr, uid, ids[0], context)
  49. ir_config_parameter_obj = self.pool['ir.config_parameter']
  50. ir_config_parameter_obj.set_param(cr,
  51. uid,
  52. 'auth_from_http_remote_user.default_login_page_disabled',
  53. repr(config.default_login_page_disabled))