UserAuth.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:1k
- <?php
- class UserAuth extends BaseObject {
- var $user_db;
- //var $crypt_passwords;
- Function UserAuth( $user_db = '' ) {
- $this->BaseObject( 'UserAuth' );
- //$this->crypt_passwords = 1;
- if ( is_object( $user_db ) ) {
- $this->user_db = $user_db;
- } else {
- $this->user_db = new User_Db();
- }
- }
- Function Get( $user_obj ) {
- $this->user_db->autocreate_user = false;
- return $this->user_db->Get( $user_obj );
- }
- Function Verify( $user_obj ) {
- $temp_obj = $user_obj;
- $temp_obj->password = undef;
- $ret_vals = $this->user_db->Get($temp_obj);
- if ( $ret_vals[ 0 ] == true ) {
- // User exists...
- $temp_usr_obj = $ret_vals[ 1 ];
- // Plaintext backwards compatibility code...
- if ( $user_obj->password == $temp_usr_obj->password ) {
- return Array( true, $temp_usr_obj );
- }
- // Encrypt the canadiate password and test it
- $crypted_password = $user_obj->EncryptPassword(
- $temp_usr_obj->password
- );
- if ( $crypted_password == $temp_usr_obj->password ) {
- return Array( true, $temp_usr_obj );
- } else {
- return Array( false, 'User not found.' );
- }
- } else {
- return Array( false, 'User not found.' );
- }
- return Array( false, 'User not found.' );
- }
- }
- ?>