FCO / classified

0 stars 0 forks source link

Initial issue #1

Open Altai-man opened 5 years ago

Altai-man commented 5 years ago

I have no better title for this ticket, please fix if any better ones.

So there are these particular issues with this app:

1)User session model has to be

model UserSession is table<logged_user> does Cro::HTTP::Auth {
    has UInt $.id is serial;
    has Str  $.sessionid is column{ :unique } is rw;
    has UInt $.uid  is referencing{ User.id } is column{ :nullable } is rw;
}

For login post route here is a diff:

-                    $session.user = $user;
-                    $session.^save;
+                    $session.uid = $user.id;

As for Session::Red module, here is a working gist - https://gist.github.com/Altai-man/546d99c3cbe4dfcd15b4ee9efa1f9ac4 with explanations added.

I was able to make it keep a session, but I am unable to update it: the next issue to look into here is that with those changes I have:

Cannot resolve caller AUTOGEN(User:D: ); none of these signatures match:
    (Mu:U: *%_)
  in block  at /home/koto/Devel/classified/lib/Routes.pm6 (Routes) line 49
  in block  at /home/koto/Work/cro/cro-http/lib/Cro/HTTP/Router.pm6 (Cro::HTTP::Router) line 130

for $session.uid = $user.id in login post route, which I don't have an idea how to fix.

Altai-man commented 5 years ago

I have working code for classified example and Cro::HTTP::Session::Red, what should I do next? A PR will do?

FCO commented 5 years ago

I’m still trying to fix that with user defined sessions... can I take a look at your code? Thanks!

Altai-man commented 5 years ago

Here is Routes.pm6: https://gist.github.com/Altai-man/f949c8ae1ef8ff0c1d513e163e192d38

About user defined sessions...

I think, the approach here is to offer a role with those fields(id, uid, session-id) and make an obligation for user to implement it. This way something like this is possible:

class CustomSession does Cro::HTTP::Session::Red::Session {
    has @.history is referencing ...
    ....
}

And, I hope, Red will handle mixed in attributes just fine.

Altai-man commented 5 years ago

Peek 2019-04-24 02-23 Here are some tests. :)

Altai-man commented 4 years ago

@FCO hi! It seems the issues were resolved, right? Can this ticket be closed?

FCO commented 4 years ago

I was trying to test it yesterday, but found a bug on .create-table: :if-not-exists while testing... now it’s fixed, I’ll try to test it again as soon as possible.