On Tue, Nov 24, 2009 at 09:27:16AM +0100, Henrik Sarvell wrote:
> I think I understand, how would I properly log someone out of the
> normal GUI, ie when using (app) et al, setting *SesId to NIL maybe? I
> just browsed http.l and noticed that variable.
I would not manipulate '*SesId'. This would just give errors due to
illegal accesses to the session.
I use "lib/adm.l", which has functions for login and logout. I'm not
sure in your case, but for terminating a session just (bye) might also
> (de usrQuit ()
> (let Usr (getUsr)
> (or Usr (redir "@logout"))))
What does 'redir' do? Something like 'redirect' in "lib/http.l"? Then it
would be better to call (logout) directly instead of redirecting to
"@logout", wouldn't it? Also, this would avoid an additional HTTP
> So the following redirects to logout if the user id is not in a cookie:
> (de logout ()
> (setq *Cookies NIL)
> (cookie 'uid NIL)
> (redir "@start"))
Same here. I would directly call 'start' or any other functions needed.
> (de signin ()
> (html 0 "RSS Reader" *Css NIL
> (form NIL
> (<table> NIL NIL NIL
> (<row> NIL "Username" (gui 'uname '(+TextField) 10))
> (<row> NIL "Password" (gui 'pwd '(+PwField) 10))
> (<row> NIL
> (gui '(+Button) "Login"
> '(let Uid (chkLogin (val> (: home uname)) (val>
> (: home pwd)))
> (if Uid
> (cookie 'uid Uid)
> (setq *Cookies (cons 'uid Uid))
> (err "Could not login.")))))
> (<row> NIL (<href> "Sign Up" "@register")))))))
> It was after pressing the Login button here I got the problem,
> redirecting to, and rendering the login form was not a problem.
Thre redirecting causes you to lose part of the session's context.
Perhaps it all works if you just do the processig directly, as I
suggested? The code will probably also become much simpler.
You could try to just use the 'login' function from "lib/adm.l", as in
"app/gui.l". I think that it has all necessary mechanisms.