Skip to content

CI4: Fix Login functionality #3640

Closed
Closed

Description

@objecttothis

There are two issue with login at this point

  • DONE. CI4 does migrations a little different. In the login view in the past we checked to see if the latest version matched by calling <?php if (!$this->migration->is_latest()): ?>. The problem is that CI4 has no is_latest(). We need to get a function working and call it in the Login controller, then add the resulting bool to the view data that gets sent with echo view('login', $data). e.g., bool $is_latest.
  • CI4 validation is different from CI3, so we need to rework how we are validating username/password.
  • We need to have the migration->latest() kick off if needed upon successful login, then logout and redirect back to the login controller.
  • CSS is not working properly. This may be app-wide, but something isn't working properly.
  • With a clean database language lines aren't loading properly.

Activity

  1. added this to the 3.4.0 milestone on Jan 30, 2023
  2. self-assigned this
    on Jan 30, 2023
  3. mormy commented on Jan 30, 2023

    @mormy

    There are two issue with login at this point

    1. CI4 does migrations a little different. In the login view in the past we checked to see if the latest version matched by calling <?php if (!$this->migration->is_latest()): ?>. The problem is that CI4 has no is_latest(). We need to get a function working and call it in the Login controller, then add the resulting bool to the view data that gets sent with echo view('login', $data). e.g., bool $is_latest.
    2. CI4 validation is different from CI3, so we need to rework how we are validating username/password.

    Hi all, I've just stumbled upon OSPOS, and have to configure it for my dad's company, and I'll probably ("probably") need to maintain it/update it down the line... saw CI3 base, hopped onto GH, saw CI4 upgrade path so:

    1. saw you already did MY_Migration, is_latest :) wanted to suggest aliasing it to your own class, but you got ahead of me

    2. if I'm reading the docs clearly, you could possibly get around this with filters (as they allow you modifying the req/res objects), but that would basically mean ... writing a whole new routing mechanism for login/logout ... yeah, not such a good idea. :)

    Thanks guys for doing this, tomorrow I'm setting up an OSPOS for the team, will be checking the progress (and contributing if I can) to any new and exciting developments :)

    TY so very, very much for this software ...

  4. objecttothis commented on Jan 30, 2023

    @objecttothis
    MemberAuthor

    @mormy. Welcome! I'm glad to hear that OSPOS is of benefit to you. Most of us who contribute to the project are like you where we have a production install that we are maintaining and our contributions to the code are primarily to benefit our needs. You are welcome to make code contributions. The CI4 conversion is beastly, so anywhere you want to help is appreciated, but of course completely voluntary.

    There is a gitter chat room. If you get stuck, post something there and hopefully someone can help you out. If you do want to make code contributions, let's try to coordinate. I have a fairly long list in the Pull Request of things that need to be done.

  5. mormy commented on Jan 30, 2023

    @mormy

    not surprised you're running into so much issues TBH, they did change A LOT in the CI 4.x branch ... all the find/replace stuff baked into modern IDEs won't help much.

    at least I can do the translation to Croatian, as this is something I must do anyways. Will checkout gitter chat if I run into problems and-or have something relevant to contribute.

    Thanks again :)

  6. objecttothis commented on Jan 30, 2023

    @objecttothis
    MemberAuthor

    not surprised you're running into so much issues TBH, they did change A LOT in the CI 4.x branch ... all the find/replace stuff baked into modern IDEs won't help much.

    at least I can do the translation to Croatian, as this is something I must do anyways. Will checkout gitter chat if I run into problems and-or have something relevant to contribute.

    Thanks again :)

    Yeah, I'm finding new stuff daily that isn't the same. Definite improvements, but they made zero effort at backward compatibility of the code.

    We use weblate for translating the interface (https://translate.opensourcepos.org/about/) so maybe @jekkos can setup a Croatian translation if there isn't one already. The CI4 changeover will add a few phrases here and there, but nothing major.

  7. objecttothis commented on Jan 30, 2023

    @objecttothis
    MemberAuthor

    Looks like Croatian is already in weblate. Create an account and have at it. It's 62% at this point.
    image

  8. mormy commented on Jan 30, 2023

    @mormy

    Looks like Croatian is already in weblate. Create an account and have at it. It's 62% at this point. image

    yeah, I saw, will do :) (have to more like it :P)

  9. jekkos commented on Jan 30, 2023

    @jekkos
    Member

    @objecttothis in CI3 there was also a db table that contains the last migration ran. I also think there was a function to get all available migrations, so this function would be compare that string with the first or last migration in the list?

  10. objecttothis commented on Jan 30, 2023

    @objecttothis
    MemberAuthor

    @objecttothis in CI3 there was also a db table that contains the last migration ran. I also think there was a function to get all available migrations, so this function would be compare that string with the first or last migration in the list?

    Yes, and that table remains the same. It's easy enough to pull the value from that table. What CI4 doesn't have is a built-in function to tell you the latest version available in the code. They wrote it so that you would just call $migrate->latest(); and it would take care of the checking for you and run the migration. Our current method warns the person that when login happens, that the migration will run. It won't be difficult to write a short function to check the \app\Database\Migrations\ directory and parse out the latest version, then pop up the warning and on login call $migrate->latest();

  11. objecttothis commented on Jan 30, 2023

    @objecttothis
    MemberAuthor

    I just pushed a fix so that it's properly checking the current version against the latest available and it now displays the warning message when there is a new version to migrate to. Yay insomnia!

  12. jekkos commented on Jan 31, 2023

    @jekkos
    Member

    Great work @objecttothis

  13. objecttothis commented on Feb 2, 2023

    @objecttothis
    MemberAuthor

    @opensourcepos/org I just pushed a commit that fixes the validation in the login controller. It took me forever. Now we just need to configure it to kick off migrations on successful login.

  14. objecttothis commented on Feb 2, 2023

    @objecttothis
    MemberAuthor

    Looks like the CI4 migrations table is much more complex (https://forum.codeigniter.com/showthread.php?tid=86564). We need to figure out how to migrate the ospos_migrations table to the CI4 structure in such a way that migrate->latest() will not try to re-run any previous migrations. This might be a little tricky because we may need to run any conversion script outside of the CI4 migrations functionality because migrations won't run without the table being the right structure. I suspect we will have to create another function in the MY_Migration class to detect when the migrations table is in CI3 format and run the sql to correct it. I have a few unanswered questions from my forum post, so I need to get those sorted out before I know how best to proceed. @mormy do you have any ideas about this?

  15. 1 remaining item

  16. objecttothis commented on Feb 4, 2023

    @objecttothis
    MemberAuthor

    The login is functionally working now, but CSS isn't being applied. I think that's more than just the login page though. We need to sort that out. Also migrations from an empty database are running properly, but the conversion from a CI3 version of OSPOS to CI4 version with migrations still needs to be worked on. That's outside the scope of this issue though. There's also an issue where on a clean database with no migrations table the language lines are not working.

  17. removed their assignment
    on Feb 5, 2023
  18. objecttothis commented on Feb 5, 2023

    @objecttothis
    MemberAuthor

    Just a note to anyone that takes this. The language lines and CSS are broken on a 3.0.2 fresh database, but just the CSS is broken on a migrated or populated database. I suspect the language lines not working is a separate issue from the CSS problems

  19. jekkos commented on Feb 5, 2023

    @jekkos
    Member

    I haven't looked at the CI4 migration system in depth yet, but if we migrate old migrations to the table, they are automatically ran again? And there is no way to override this behavior, eg by flagging the migration as done or setting a version somewhere past their timestamps?

  20. jekkos commented on Feb 5, 2023

    @jekkos
    Member

    That would be a nice issue title, migrate the migrations.

  21. objecttothis commented on Feb 5, 2023

    @objecttothis
    MemberAuthor

    I haven't looked at the CI4 migration system in depth yet, but if we migrate old migrations to the table, they are automatically ran again? And there is no way to override this behavior, eg by flagging the migration as done or setting a version somewhere past their timestamps?

    This is what I just fixed. For anyone on an OSPOS 3.0.2 to 3.3.8 version, OSPOS converts their migration table to CI4 format and adds rows in to that table manually so that no migrations get run again. Then it proceeds like it did before (check if it's the latest > migrate on login to latest).

  22. objecttothis commented on Feb 5, 2023

    @objecttothis
    MemberAuthor

    That would be a nice issue title, migrate the migrations.

    Yeah, that's almost what I named the issue #3647

  23. mormy commented on Feb 6, 2023

    @mormy

    Looks like the CI4 migrations table is much more complex (https://forum.codeigniter.com/showthread.php?tid=86564). We need to figure out how to migrate the ospos_migrations table to the CI4 structure in such a way that migrate->latest() will not try to re-run any previous migrations. This might be a little tricky because we may need to run any conversion script outside of the CI4 migrations functionality because migrations won't run without the table being the right structure. I suspect we will have to create another function in the MY_Migration class to detect when the migrations table is in CI3 format and run the sql to correct it. I have a few unanswered questions from my forum post, so I need to get those sorted out before I know how best to proceed. @mormy do you have any ideas about this?

    sorry, no, not at the moment, .... docker compose doesn't work on windows 11 with WSL2 (CI3 base v3.3.8), there is a lot of broken stuff, dealing with that (also documentation is ... lacking, so fixing that first).

    I would do a separate tool for migrating CI3 > CI4, and for now would flag CI4 support as for "new installs only", due to having a lot more stuff to do before tackling the migration problems ...

  24. objecttothis commented on Feb 6, 2023

    @objecttothis
    MemberAuthor

    Thanks. Migrations is now sorted. We just need to have several people test it against copies of their production database to work out any kinks.

  25. objecttothis commented on Feb 6, 2023

    @objecttothis
    MemberAuthor

    I think I see why the CSS isn't working properly. On my dev box the \public\bower_components folder has not been created and populated. @jekkos @SteveIreland or @odiea do any of you know how these properly get generated?

  26. SteveIreland commented on Feb 6, 2023

    @SteveIreland
    Collaborator

    Yes, it's part of the build process. That was part of the fix I needed to make since it updates some of the PHP files with the minimized css file name. I'll try to submit the fix in the next day or two.

  27. jekkos commented on Feb 6, 2023

    @jekkos
    Member

    @objecttothis these files are downloaded when you type bower install. after that a grunt should create the minified versions

  28. SteveIreland commented on Feb 7, 2023

    @SteveIreland
    Collaborator

    I added a commit that fixes the conventional (non-docker) build. There are some changes needed for the Docker scripts, but I don't yet have docker installed on my current box so I wouldn't be able to test them. I did not need to include --force on the grunt step.

  29. objecttothis commented on Feb 18, 2023

    @objecttothis
    MemberAuthor

    In order to fix the language lines not loading properly I had to fix the default language code assigned in tables.sql. That was set to 'en' I changed it to 'en-US'. I think a long time ago 'en' is what we were using for the default language, but since we had to move to locales separating 'en-US' and 'en-GB' there no longer is an 'en' in \app\Language\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions