Page 2 of 2

Re: Osirose II registration script issue

PostPosted: Wed May 02, 2018 9:54 pm
by aerocoke
lazypenguin wrote:Does it work when you use the stored procedure ?

  1.  
  2. if (isset($_POST['username']) && isset($_POST['password'])){    
  3.         $username= $_POST['username'] ;
  4.         $password = $_POST['password'];
  5.  
  6.         $sql = "call create_account(${username}, ${password})";
  7.         $query = mysqli_query($connection, $sql) ;
  8.  


I don't know PHP so YMMV...


I tried
  1. $sql = $connection->query("call create_account"(${username}, ${password}));
but gives me the 'Call to undefined function' error.

Re: Osirose II registration script issue

PostPosted: Wed May 02, 2018 10:46 pm
by lazypenguin
The function is defined here: https://github.com/dev-osrose/osIROSE-n ... e.sql#L393

You might want to try rebuilding your database if that stored procedure is not working. You can also see how the stored procedure creates an account. Basically:

  1.  
  2. SET @salt = create_salt();
  3. INSERT INTO accounts(username, password, salt) VALUES(_user, SHA2( CONCAT(_pass,@salt), 256), @salt);
  4. SET @salt = NULL;
  5.  

Re: Osirose II registration script issue

PostPosted: Thu May 03, 2018 6:24 pm
by L3nn0x
The order you are doing things is wrong.

You need to first concatenate the password and the salt and then call sha256 on it. Store the result in the database.

But you should use the stored procedure. We created it so you wouldn't have to worry about salts and the such :)

Re: Osirose II registration script issue

PostPosted: Thu May 03, 2018 11:05 pm
by XxXshidoXxX
aerocoke wrote:
lazypenguin wrote:Does it work when you use the stored procedure ?

  1.  
  2. if (isset($_POST['username']) && isset($_POST['password'])){    
  3.         $username= $_POST['username'] ;
  4.         $password = $_POST['password'];
  5.  
  6.         $sql = "call create_account(${username}, ${password})";
  7.         $query = mysqli_query($connection, $sql) ;
  8.  


I don't know PHP so YMMV...


I tried
  1. $sql = $connection->query("call create_account"(${username}, ${password}));
but gives me the 'Call to undefined function' error.

The issue here is i believe the php syntax.
Try

  1. $query = $connection->query("CALL create_account('$username','$password')") ;

Re: Osirose II registration script issue

PostPosted: Fri May 04, 2018 4:14 pm
by L3nn0x
Oh nice catch, I didn't see that the parenthesis are outside the string.
I second that answer

Re: Osirose II registration script issue

PostPosted: Sat May 12, 2018 10:28 pm
by Raven0123
FYI The create_account stored procedure expects that you are passing it a MD5 hashed password. It will not hash it for you.

Re: Osirose II registration script issue

PostPosted: Sat May 12, 2018 10:49 pm
by XxXshidoXxX
Raven0123 wrote:FYI The create_account stored procedure expects that you are passing it a MD5 hashed password. It will not hash it for you.


That explains why mine didn't work either, was too embarrassed to post about it lol.

Re: Osirose II registration script issue

PostPosted: Sun May 13, 2018 1:34 pm
by L3nn0x
Oups, totally forgot about that. It's been so long since I last added an account from outside the server.