how to create user from other project like dotproject ??

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
PHPycho
Posts: 13
Joined: 16 Mar 2007, 10:31

how to create user from other project like dotproject ??

Post by PHPycho »

Hello forums !!
I tried to create users from dotproject. and i was successful also....But what went wrong is the user was not able to login with the username and password that was created using dotproject. When i checked the mantis_user_table then i saw there the cookie_string field was empty..
Can anybody tell me how to generate the cookie_string from dotproject so that i can be success in creating users from dotproject.
thanks in advance to all of you !!
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Post by vboctor »

Are you using some sort of integration library that integrates dotProject with Mantis? If so, then you should report this as a bug against this library.
Migrate your MantisBT to the MantisHub Cloud
PHPycho
Posts: 13
Joined: 16 Mar 2007, 10:31

Post by PHPycho »

thanks for the reply
But what i want is to insert the required cookie_string from the dotproject .
How is that possible ?
I would be very greatful if i got the solution.
Thanks in advance .
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Post by vboctor »

You can use the following code from core/user_api.php to set the value for the cookie:

Code: Select all

$t_seed				= $p_email . $p_username;
$t_cookie_string	= auth_generate_unique_cookie_string( $t_seed );
Migrate your MantisBT to the MantisHub Cloud
PHPycho
Posts: 13
Joined: 16 Mar 2007, 10:31

Post by PHPycho »

Thanks for the reply..i used to the following and its working

Code: Select all

/* Creating the Cookie_String */
	# --------------------
	# Generate a UNIQUE string to use as the identifier for the login cookie
	# The string returned should be 64 characters in length
	function auth_generate_unique_cookie_string() 
	{
		
		do 
		{
			$cookie_string = auth_generate_cookie_string();
		} 
		while ( !auth_is_cookie_string_unique( $cookie_string ) );
		
		return $cookie_string;
	}
	# --------------------
	# Generate a string to use as the identifier for the login cookie
	# It is not guaranteed to be unique and should be checked
	# The string returned should be 64 characters in length
	function auth_generate_cookie_string() 
	{
		$t_val = mt_rand( 0, mt_getrandmax() ) + mt_rand( 0, mt_getrandmax() );
		$t_val = md5( $t_val ) . md5( time() );

		return substr( $t_val, 0, 64 );
	}	
	# --------------------
	# Return true if the cookie login identifier is unique, false otherwise
	function auth_is_cookie_string_unique( $cookie_string ) 
	{
		global $mantis_user_table;
		$query = "SELECT *
				  FROM $mantis_user_table
				  WHERE cookie_string='$cookie_string'";
		$result = mysql_query( $query );
		$count = mysql_num_rows( $result );
		//echo $count;
		if ( $count > 0 ) 
		{
			return false;
		} 
		else 
		{
			return true;
		}
	}



			$seed = $email . $username;
		    $cookie_string	= auth_generate_unique_cookie_string( $seed );
Post Reply