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 !!
how to create user from other project like dotproject ??
Moderators: Developer, Contributor
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
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
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 );