Source for file _auth.php

Documentation is available at _auth.php

  1. <?php
  2.  
  3. class net_nemein_registrations__auth {
  4. var $_midgard;
  5. var $_person;
  6. var $_ispoweruser;
  7.  
  8. var $_topic;
  9. var $_config;
  10. function net_nemein_registrations__auth ($topic, $config) {
  11. $this->_topic = $topic;
  12. $this->_config = $config;
  13. $this->auth_sync_with_midgard();
  14. }
  15. function get_midgard() { return $this->_midgard; }
  16. function get_person() { return $this->_person; }
  17. function is_poweruser() { return $this->_ispoweruser; }
  18. function auth_sync_with_midgard() {
  19. $this->_clear_privileges();
  20. $this->_midgard = mgd_get_midgard();
  21. $this->_person = mgd_get_person($this->_midgard->user);
  22. if (! $this->_person)
  23. $this->_person = null;
  24. $this->_read_privileges();
  25. }
  26. function auth_registrar (&$regfact, $email, $password) {
  27. $person = $regfact->getby_email($email);
  28. if (is_null($person)) {
  29. debug_add("could not get person record for '$email'");
  30. $this->auth_sync_with_midgard();
  31. return false;
  32. }
  33. if ($person->parameter("net.nemein.registrations", "password") != $password) {
  34. debug_add("Passwords do not match, got '$password', should be '"
  35. . $person->parameter("net.nemein.registrations", "password") . "'");
  36. $this->auth_sync_with_midgard();
  37. return false;
  38. }
  39. $this->_person = $person;
  40. $this->_read_privileges();
  41. return true;
  42. }
  43. function _read_privileges() {
  44. if (is_null ($this->_person)) {
  45. $this->_clear_privileges();
  46. } else {
  47. if ($this->_person->id == $this->_midgard->user && $this->_midgard->admin)
  48. $this->_is_poweruser = true;
  49. else
  50. $this->_ispoweruser = $this->_person->parameter("Interface","Power_User") != "NO" ? true : false;
  51. }
  52. }
  53. function _clear_privileges() {
  54. $this->_person = null;
  55. $this->_ispoweruser = false;
  56. }
  57. }
  58. ?>

Documentation generated on Mon, 21 Nov 2005 18:25:04 +0100 by phpDocumentor 1.3.0RC3