login-maybe widget

22 views
Skip to first unread message

Fred

unread,
Dec 6, 2012, 4:18:29 PM12/6/12
to webl...@googlegroups.com
Hello,

I would like your opinion about something i've found about the login-maybe widget example from :

In the example, the check-login function is in charge of :
- check the credentials
- bounds the real-child-widget slot with the widget created from the contents of the child-widget slot

So, if i need to store some data in the session, i have to return an objet from the check-login function.
The check-login function is called from the quickform-form/satisfies lambda
and if the function return a not nil value, the value is stored in the session.

Now, if i need data stored in the session in the new created child widget, with the example above i can't.
i can't because the lambda in charge of the creation of the child widget is called before
the   (setf (webapp-session-value *authentication-key*) success)  (see login.lisp).
And the call to  (webapp-session-value *authentication-key*) return true, not the data i wants.

So the solution i've found is :
1) let the check-login function stored in the on-login slot only in charge of check the credentials
2) bound a new function in the on-success slot in charge of the creation of the children widget.


So in the example of digikam blog,
the code should be



(defun check-login (login-widget credentials-obj) 
"Check the user's login credentials" 
  (declare (ignore login-widget)) 

  (let* ((login (slot-value credentials-obj 'name))

(passwd (slot-value credentials-obj 'passwd))

    (user (search-user login passwd))))

    (or user (values nil "User not found or incorrect password"))))

(defun create-cihldren (login-widget credentials-obj)
 (when 
   (login-maybe-child-widget login-widget) 
   (setf (slot-value login-widget 'real-child-widget) (funcall (login-maybe-child-widget login-widget))) 
   (setf (login-maybe-child-widget login-widget) nil))) 

Here's some usage 

(make-navigation 

'main-menu 
'home (make-main-page) 
'self (make-instance 
'login-maybe 

:on-success #'create-children
:on-login #'check-login 
:child-widget (make-self-page)) 

am i right ?

Thanks.

Best regards.




Reply all
Reply to author
Forward
0 new messages