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.

64 lines
3.0 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. class auth_from_http_remote_user_configuration(orm.TransientModel):
  24. _inherit = 'base.config.settings'
  25. _columns = {
  26. 'default_login_page_disabled': fields.boolean("Disable login page when "
  27. "login with HTTP Remote "
  28. "User",
  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. vals = self.get_default_default_login_page_disabled(cr,
  38. uid,
  39. fields,
  40. context=context)
  41. return vals.get('default_login_page_disabled', False)
  42. def get_default_default_login_page_disabled(self, cr, uid, fields,
  43. context=None):
  44. icp = self.pool.get('ir.config_parameter')
  45. # we use safe_eval on the result, since the value of
  46. # the parameter is a nonempty string
  47. is_disabled = icp.get_param(cr, uid, 'default_login_page_disabled',
  48. 'False')
  49. return {'default_login_page_disabled': safe_eval(is_disabled)}
  50. def set_default_default_login_page_disabled(self, cr, uid, ids,
  51. context=None):
  52. config = self.browse(cr, uid, ids[0], context=context)
  53. icp = self.pool.get('ir.config_parameter')
  54. # we store the repr of the value, since the value of the parameter
  55. # is a required string
  56. icp.set_param(cr, uid, 'default_login_page_disabled',
  57. repr(config.default_login_page_disabled))