midgard_user

Posted on 2007-04-12 14:59:05 EEST.

midgard_user class is something completely new in Midgard2 architecture. This is something which completely separates midgard_person object from its account. User type , login , password its kept by midgard_user for which you can assign midgard_person.

Login and password is known for everyone, but there are two new cool user features.

  • Person account can be active or inactive. You may have midgard_person record and its midgard_user record, but as long as person's account is inactive you can not login in.

  • You decide what's the way to encrypt and decrypt your password.

Create account for person.

$person = new midgard_person();
$person->username = "John";
$person->lastname = "Smith";
$person->sitegroup = 1; /* replace it with something more suitable */

$person->create();

$user = new midgard_user($person);
$user->password("mylogin", "mypassword");

Third optional argument is ommited here. But if need you can use:

  • MD5 hash ( default one )
  • Plain text
  • SHA1 ( not yet supported )
  • PAM

PAM seems to be interesting here as you can define typical Virtual Host and use PAM authentication type for selected users only.

Once account is created, you may log in.

midgard_user::auth('mylogin', 'mypassword', 'My Test Sitegroup');

Sitegroup name must be set explicitly as another argument. Unlike Midgard1 architecture. To make things even more flexible, you are able to use fourth optional argument: trusted auth type ( FALSE by default ).

midgard_user::auth('mylogin', 'mypassword', 'My Test Sitegroup', TRUE);

In this step you do not have to define your hash type. If you want to change it, use password method.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS