portapipe / Login-GroceryCrud

A Login/Logout system for GroceryCrud (codeigniter).
32 stars 26 forks source link

Do you plan to support Grocery Crud Enterprise Edition? #13

Open yusuf-mutlu opened 6 years ago

yusuf-mutlu commented 6 years ago

Hello,

I like this Login-GroceryCrud job. I have used this with grocery crud community edition and helped me a lot. Do you plan to support also Enterprise Edition? It would be amazing if you could. :)

portapipe commented 6 years ago

Thanks @RudyardKipling :) This plugin is optimized for GroceryCrud but it's basically matchable with any project! Give it a try and let me know, but I think I'll add the Enterprise Edition support.

yusuf-mutlu commented 6 years ago

I have been trying to manage permissions for Enterprise Edition but i couldn't know how to set the library for Enterprise Edition.

image

yusuf-mutlu commented 6 years ago

I think now i have some reasonable errors after setting up the library properly. :)

Reasonable Erors :)

yusuf-mutlu commented 6 years ago

I have been trying to integrate Grocery Crud Enterprise with Codeigniter framework by the way. This Login-GroceryCrud integration really needs a grocery crud expert :)

portapipe commented 6 years ago

@RudyardKipling 403 on the screenshots you've sent for reasonable errors... I can help you integrate it, just post the errors and let's try...

yusuf-mutlu commented 6 years ago

I am trying tests for grocery crud standart example database. When checking a table's permissions for a user i am having this error on Login_model.php on line 125

"Type: PDOException Message: You cannot serialize or unserialize PDO instances"

image

My code for test is: image

How can i solve this?

I solved this, i had to check crud before rendering. this is ok. :)

yusuf-mutlu commented 6 years ago

1.) Now, i dont get errors for checking my crud with Login_model.php. But although i set edit, add and delete permissions for my crud, i cannot see edit, add, delete options on my crud.

Here is my code: image

And my output crud: image

2.) I can render manage_permissions without errors: image

But when i try to save my permissions i am having some ajax errors: image

yusuf-mutlu commented 6 years ago

For 1st matter above i mentioned, i recognised something.

The problem is about check function in Login_model.php. Table name cannot be unserialized correctly. Because of this, every condition about crud returns false and it behaves like there is no permission.

If you can tell me how to debug crud variable, i can find a way.

image

portapipe commented 6 years ago

How many odds issues... I had to ask you what you need to do, then I can suggest stuff :P I thought you had to make a simple login but if you need some advanced stuff let me know which ones

yusuf-mutlu commented 6 years ago

I know the issues i wrote looks like a mess :s I just want to make Login-GroceryCrud work for GroceryCrud EnterPrise like it works perfect for GroceryCrud Community edition. The simple usage is enough for me.

If i solve the 2 matters i wrote above, then everything will be fine. I really like Grocery Crud and your Login system, i have become fan of you and John by time. :))

Thanks for your kindness. :)

portapipe commented 6 years ago

Oh thanks man! I think @scoumbourdis will be happy for that. I think that I’ve saw the serialize issue once... I did a simple change that I don’t remember atm, it was tricky but few lines indeed... I’ll check that for you but if this is the only problem I think is fully compatible with the enterprise edition! 00:25 here, today I’m gonna check that for you :)

scoumbourdis commented 6 years ago

Hello guys,

I would love to start using it in Grocery CRUD Enterprise and have an official example at the website. But as @portapipe already knows my time is very very limited and already promised him something that I still can't find the time to do. The good news is that everything is within a backlog so they will not be forgotten. The bad news is that my backlog is huge 😄

Currently working to finish the bootstrapV4 theme for grocery CRUD Enterprise that will be available probably this week (I will announce it in twitter) and at the same time I did finish creating a YouTube video (Which PHP Framework is best for you? 2018 update) and all of these on my public holidays (Orthodox Easter) but I like to work on these stuff so I am not regretting it :)

portapipe commented 6 years ago

Well that’s cool enough, built directly in the enterprise edition in the next future! For now let me go to work so I can take a look at the changes I did for that issue... Don’t worry John, I have a though moment at work too, plus new clients with jobs... but that jobs probably will need some extra stuff so... you know what I’m talking about ;)

yusuf-mutlu commented 6 years ago

@scoumbourdis If you could make an official example about Login-GroceryCrud it would be wonderful. An easy to use awesome crud(Grocery Crud) and an easy to use awesome login system(Login-GroceryCrud), what can a developer want more for starting a project in lightning speed. :) Keep up the great work. My best wishes with who contributes to these projects. :)

portapipe commented 6 years ago

@RudyardKipling comment the first $state declaration and change the second one as following:

                /*
        $state = unserialize(
            preg_replace(
                '/^O:\d+:"[^"]++"/', 
                'O:'.strlen("portapipe").':"portapipe"',
                serialize($crud)
            )
        );
        */
        //$state = json_encode((array)$state);
        $state = json_encode((array)$crud);
        $state2 = strpos($state,'basic_db_table":"');
        $state = str_replace('basic_db_tab.....................

and let me know if it works.

yusuf-mutlu commented 6 years ago

@portapipe I have figured out that, there is no need to change unserialize or json_encode code. If I replace 'basic_db_table' with 'dbTableName' everything works fine.

//$state2 = strpos($state,'basic_db_table":"'); //$state = str_replace('basic_db_table":"','',substr($state, $state2));

$state2 = strpos($state,'dbTableName":"'); $state = str_replace('dbTableName":"','',substr($state, $state2));

1st problem i mentioned above is ok now. :)

Now i am trying to save manage_persmissions. I get some javascript error. If i solve this, too. I will be very happy. :))

yusuf-mutlu commented 6 years ago

For the 2nd problem i have, it is because of difference between EnterPrise and Community Edition's callbackBeforeUpdate and callbackBeforeInsert functions. I have to rewrite Login-GroceryCrud's some functions:

image

portapipe commented 6 years ago

@RudyardKipling great work!

scoumbourdis commented 6 years ago

Hey @RudyardKipling great work,

Can you please copy the example that you did use at https://gist.github.com/ so it will be easier for me to create examples for Grocery CRUD Enterprise?

Please just share your controller only as this is enough for people to understand.

Regards Johnny

yusuf-mutlu commented 6 years ago

@scoumbourdis I am using codeigniter framework. Theese are the files i edited for Enterprise Edition.

You can reach Login.php's edited version from Login-GroceryCrud: https://gist.github.com/RudyardKipling/9b7ef9dc8cfbfdbcbc3fc335de223fb1

Examples controller: https://gist.github.com/RudyardKipling/695358b2f7e8e4820c88b614b167ad58

Login_model.php from Login-Grocery Crud. https://gist.github.com/RudyardKipling/800f3d54e3c52b98b0be464bb4bd6229

I want to make something clear. I couldn't make work manage_permissions function from Login.php. I still need help for this. :)

yusuf-mutlu commented 6 years ago

I couldn't make "manage_permissions" functions work with GroceryCrud Enterprise edition. If it is solved, Login-GroceryCrud system will be fully compitable with GroceryCrud Enterprise edition.

I need some help plz. :/

image

portapipe commented 6 years ago

@RudyardKipling the error shown below tells nothing. You have to look inside the page you're calling and that throws error. A better debug can show the issue. I think is something related edited function names like "unset_edit/add/delete" or stuff like that. I'm not using Enterprise ATM so I can't help as I want but I'm here if you need more help.

yusuf-mutlu commented 6 years ago

For the "manage_permissions" issue, after hours i have decided to use CommunityEdition for only "manage_permissions" function. Thats not a good way but somehow it is a solution. :D I will be using both Community and Enterprise Edition in my projects same time depends on the situation. Thanks for your kindness and helps.

portapipe commented 6 years ago

I just have to take a look on how the Enterprise Edition do stuff but with a bit of effort you could figure out by yourself :)

nyala1 commented 5 years ago

Did you guys ever come up with a working login system for stand-alone Enterprise Edition or CodeIgniter package?

portapipe commented 5 years ago

Hi nyala1. This Login system work with Codeigniter alone. The permission grid is the only one that require GroceryCrud at the moment. I’m secretly planning on create an enhanced version of it, but it will take some time and I’m having a high work requests since a year, but I want to revolutionize the permission management 🙂

nyala1 commented 5 years ago

Hi, and thanks for your unexpectedly quick response. I'm happy that this projects till has your attention as it could be really useful. :)

The delay in my response is because I wanted to get it up and running before responding and I am stuck. I'm sure that I am doing something simple wrong as I have followed your instructions but I get a successful login message, "HI admin! You are Logged IN!" but then I get a model with, for starters, a parse error:"


We can\'t process the response of the server. This is all we know about it: Summary:parsererror Error:SyntaxError: Unexpected token H in JSON at position 0


I've tried everything I can think of but it must be outside my abilities. Any help I can get from you would be greatly appreciated. I just need to be pointed in the right direction:)

If you give me an email address I can send you a link to my sandbox so you can see for yourself.

Regards,

Marv

portapipe commented 5 years ago

Hi @nyala1 , I think this is not a GCLogin related issue... I can suggest you to make a step-by-step code debug (like add a echo 'from here it's all fine';die; line by line on the page that throws that error) then came back here if it still happen.

nyala1 commented 5 years ago

Hi, I've worked on this for some time and cannot figure it out. I can tell you however that if I add the GCLogin code to the function I want to be protected it fails and if I don't add it everything works so seems it is at least related to your code. For example the following throws the error but if I remove your code it works as expected. I'm at a loss unless I'm adding your code incorrectly.?

public function requests() { $this->load->model("login_model");

if($this->login_model->isLogged()){ $name = $this->loginmodel->name(); echo "HI $name! You are Logged IN!"; }else{ redirect("/login"); }



    $crud = $this->_getGroceryCrudEnterprise();
    $crud->setTable('quotes');
    $crud->setSubject('Trip Request', 'Open Trip requests');
    $crud->columns(['id','qdate','origin','destination','date','pax','actype']);

        if ($crud->getState() === 'Initial') {
    $origin_dropdown = [];
    $this->db->distinct();
    $this->db->select('origin');
    $this->db->order_by('origin');
    foreach ($this->db->get('quotes')->result() as $row)`
portapipe commented 5 years ago

The code seems fine... The error says that there is an unexpected H and the only one that I see is in the echo message... can you try to change it and see what’s going on? Try a line by line debug on that few lines...

nyala1 commented 5 years ago

I have tried the line by line debugging and we're good all the way through the penultimate line where we render it. If you look at the code below and look at where I have echo "from here it's all fine";die; ----- It's when I move the debug code below the last line "$this->_example_output($output);" that we get the error.

`public function requests() { $this->load->model("login_model");

if($this->login_model->isLogged()){ $name = $this->login_model->name(); echo "HI $name! You are Logged IN!"; }else{ redirect("/login"); }

$crud = $this->_getGroceryCrudEnterprise();

$crud->setTable('quotes');
$crud->setSubject('Trip Request', 'Open Trip requests');
$crud->columns(['id','qdate','origin','destination','date','pax','actype']);

    if ($crud->getState() === 'Initial') {
$origin_dropdown = [];
$this->db->distinct();
$this->db->select('origin');
$this->db->order_by('origin');

foreach ($this->db->get('quotes')->result() as $row) {
    $origin_dropdown[$row->origin] = $row->origin;
}

$crud->fieldType('origin', 'dropdown_search', $origin_dropdown);

} if ($crud->getState() === 'Initial') { $destination_dropdown = []; $this->db->distinct(); $this->db->select('destination'); $this->db->order_by('destination'); foreach ($this->db->get('quotes')->result() as $row) { $destination_dropdown[$row->destination] = $row->destination; } $crud->fieldType('destination', 'dropdown_search', $destination_dropdown); }

$output = $crud->render();
    echo "from here it's all fine";die;//This is as far as I can get error free

$this->_example_output($output);

//if I move the debug code here we get the error. } `


//If you send me an email address I will send you a link to the sandbox

nyala1 commented 5 years ago

A couple additional thoughts...

Remember that this is GC Enterprise not community (although I can’t see where that would matter)

All the existing code before adding GCLogin code was personally “Johnney Approved.” So I think it’s good.

Given that the errors only present themselves after the output statement I am really confused. The error seems to be because of something returned in the Json return. Can’t inagine what that could have to do with your code but nonetheless if I remove your code it all works fine.

Is there something so should have in your config file that could be wrong?

Thanks for your continued help!!

portapipe commented 5 years ago

I don't think is a PHP version issue, so I think you can put some "return;" or "die;" in my library and model, just to make a line by line debug of the GCLogin library too. This is what I'd do.

yusuf-mutlu commented 5 years ago

Hi, I am writing for people who has concerns about Grocery Crud Enterprise working with Login-Grocery Crud. I am using theese two for months, they are really very very good together. With help of theese awesome 2 libraries, I am able to finish a project in a day that can be finished in a week.

If you want to use Login-Grocery Crud with Enterprise version, you just need to change check function in Login_model.php. I have the sample that working well with Enterprise: https://gist.github.com/RudyardKipling/2c3e1a9f3b638f75c95ec0542018b542

Only on Manage Permissions screen, i am using community edition and everything is fine.

nyala1 commented 5 years ago

Thanks but could you please be a bit clearer? The code you provided doesn't really illustrate where to make the change effectively, at least with my abilities :)

Thanks! ᐧ

On Tue, Sep 18, 2018 at 5:59 PM RudyardKipling notifications@github.com wrote:

Hi, I am writing for people who has concerns about Grocery Crud Enterprise working with Login-Grocery Crud. I am using theese two for month, they are really very very good together. With help of theese awesome 2 libraries, I am able to finish a project in a day that can be finished in a week.

If you want to use Login-Grocery Crud with Enterprise version, you just need to change check function in Login_model.php. I have the sample that working well with Enterprise.

On manage permissions screen, i am using just community edition and everything is fine.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/portapipe/Login-GroceryCrud/issues/13#issuecomment-422571285, or mute the thread https://github.com/notifications/unsubscribe-auth/AGJBJ5cWu3u0X5EnJUQD5ndCl1VUTEifks5ucWyngaJpZM4TLdu5 .

-- Regards,

M Steigman

harshalone commented 5 years ago

I have the same problem : https://www.bylde.com/admin/users/test