Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Checking user session in model
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Novice Programmer  
View profile  
 More options Mar 6 2008, 11:49 am
From: "Novice Programmer" <novice.prog...@gmail.com>
Date: Thu, 6 Mar 2008 22:19:06 +0530
Local: Thurs, Mar 6 2008 11:49 am
Subject: Checking user session in model

Hello All,

I want to thro a validation error if a user is not logged in. This is
because i have a mechanism to display model validation errors in the view
and dont want to add controller level error displaying handler. Please
suggest that how can i proceed to check the session in the model. I dont
think that it is possible to access Session component in the model. Is It?

--
Thanks & Regards,
Novice (http://ishuonweb.wordpress.com/).


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Baz  
View profile  
 More options Mar 6 2008, 1:09 pm
From: Baz <bazil...@gmail.com>
Date: Thu, 6 Mar 2008 12:09:15 -0600
Local: Thurs, Mar 6 2008 1:09 pm
Subject: Re: Checking user session in model

Anything is possible...

But I think the general consensus is that you should not.

With that said, please remember that with MVC we are still dealing with
classes, member variables and methods here.

There is nothing stopping you from assigning a Model member variable in your
controller, based on the session, then using that in your Model code as
needed.

On Thu, Mar 6, 2008 at 10:49 AM, Novice Programmer <novice.prog...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MattC  
View profile  
 More options Mar 6 2008, 1:54 pm
From: MattC <m...@mcurry.net>
Date: Thu, 6 Mar 2008 10:54:40 -0800 (PST)
Local: Thurs, Mar 6 2008 1:54 pm
Subject: Re: Checking user session in model
Or you can cheat and use $_SESSION...but you didn't hear that from me.

-Matt
www.pseudocoder.com

On Mar 6, 1:09 pm, Baz <bazil...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Novice Programmer  
View profile  
 More options Mar 6 2008, 2:01 pm
From: "Novice Programmer" <novice.prog...@gmail.com>
Date: Fri, 7 Mar 2008 00:31:11 +0530
Local: Thurs, Mar 6 2008 2:01 pm
Subject: Re: Checking user session in model

Hello Baz,

What do you suggest then? Should i assign the value of error in controller
to the array that comes out from validation? Doesn't it break MVC paridigm.
I mean model is supposed to give us data and we are still not satisifed with
what it has outputted to us?

Thanks.

--
Thanks & Regards,
Novice (http://ishuonweb.wordpress.com/).

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Novice Programmer  
View profile  
 More options Mar 6 2008, 2:24 pm
From: "Novice Programmer" <novice.prog...@gmail.com>
Date: Fri, 7 Mar 2008 00:54:25 +0530
Local: Thurs, Mar 6 2008 2:24 pm
Subject: Re: Checking user session in model

$_SESSION... :(.. .This will even break cake paradigms along with the MVC
paradigms.. one on one free bonanza... :).. Just kidding..

--
Thanks & Regards,
Novice (http://ishuonweb.wordpress.com/).

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Baz  
View profile  
 More options Mar 6 2008, 4:41 pm
From: Baz <bazil...@gmail.com>
Date: Thu, 6 Mar 2008 15:41:45 -0600
Local: Thurs, Mar 6 2008 4:41 pm
Subject: Re: Checking user session in model

Dude, you asked the question.

MVC is a nice model, but if you claim you "NEED" something that it doesn't
support please understand that it's just a bunch of classes.

On Thu, Mar 6, 2008 at 1:01 PM, Novice Programmer <novice.prog...@gmail.com>
wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Novice Programmer  
View profile  
 More options Mar 6 2008, 6:50 pm
From: "Novice Programmer" <novice.prog...@gmail.com>
Date: Fri, 7 Mar 2008 05:20:33 +0530
Local: Thurs, Mar 6 2008 6:50 pm
Subject: Re: Checking user session in model

yeah thats another way... I got another way though ... will do the
controller errors using the hidden divs and enable them in view when
controller throws an error.. what say?

Thanks.

--
Thanks & Regards,
Novice (http://ishuonweb.wordpress.com/).

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dardo Sordi Bogado  
View profile  
 More options Mar 6 2008, 8:33 pm
From: "Dardo Sordi Bogado" <dardoso...@gmail.com>
Date: Thu, 6 Mar 2008 23:33:19 -0200
Local: Thurs, Mar 6 2008 8:33 pm
Subject: Re: Checking user session in model
Auth should go in controller, that said you can assign the session
object to the model $this->Model->Session = $this->Session;

On Thu, Mar 6, 2008 at 9:50 PM, Novice Programmer


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rtconner  
View profile  
 More options Mar 6 2008, 8:56 pm
From: rtconner <rtcon...@gmail.com>
Date: Thu, 6 Mar 2008 17:56:18 -0800 (PST)
Local: Thurs, Mar 6 2008 8:56 pm
Subject: Re: Checking user session in model
global $SESSION;
$SESSION = $this->Session;

screw this not getting at the session from the model crap, there are
exceptions to every rule and this is one of them

On Mar 6, 6:33 pm, "Dardo Sordi Bogado" <dardoso...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
nate  
View profile  
(2 users)  More options Mar 6 2008, 9:13 pm
From: nate <nate.ab...@gmail.com>
Date: Thu, 6 Mar 2008 18:13:35 -0800 (PST)
Local: Thurs, Mar 6 2008 9:13 pm
Subject: Re: Checking user session in model
On Mar 6, 8:56 pm, rtconner <rtcon...@gmail.com> wrote:

> global $SESSION;
> $SESSION = $this->Session;

> screw this not getting at the session from the model crap, there are
> exceptions to every rule and this is one of them

rtconner:
OMG u r teh N00Bzorz!!1one!

Novice Programmer:
There are two right ways of doing this.  One is to make the session a
formal part of your domain model, i.e. model it.  This allows it to
interact with other models at the model level.  The model, like the
view, should never directly query a tier outside its own.  The other
is to use a callback to notify the model of the user's state.
Assuming you are following proper convention, this can be handled
across your entire application in one fell swoop:

class AppController extends Controller {

    var $components = array("Auth");

    function beforeFilter() {
        $this->{$this->modelClass}->setUserState($this->Auth->user());
   }

}

class AppModel extends Model {

    function setUserState($user) {
        // Handle authentication data/set local variables in prep for
validation
    }

}

Hope that helps.  If you're not able to get it to work, reply to this
thread and myself or someone else knowledgeable in proper OO/MVC
design will respond.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
rtconner  
View profile  
 More options Mar 6 2008, 9:25 pm
From: rtconner <rtcon...@gmail.com>
Date: Thu, 6 Mar 2008 18:25:28 -0800 (PST)
Local: Thurs, Mar 6 2008 9:25 pm
Subject: Re: Checking user session in model
Ya Novice Programmer, don't listen to me. It's not recomended.

Nate:
You be happy to know, one of my favourite bootrap functions ..
function user($key = null) {
    global $AUTH_COMPONENT;
    return $AUTH_COMPONENT->user($key);


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
nate  
View profile  
 More options Mar 6 2008, 9:31 pm
From: nate <nate.ab...@gmail.com>
Date: Thu, 6 Mar 2008 18:31:31 -0800 (PST)
Local: Thurs, Mar 6 2008 9:31 pm
Subject: Re: Checking user session in model
Dude, Rob, you can be as proletarian as you want in your own
applications, just don't come polluting our mailing list with your
uneducated drivel.

On Mar 6, 9:25 pm, rtconner <rtcon...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vangel  
View profile  
 More options Mar 6 2008, 10:40 pm
From: Vangel <Abhishek.Duj...@gmail.com>
Date: Thu, 6 Mar 2008 19:40:56 -0800 (PST)
Local: Thurs, Mar 6 2008 10:40 pm
Subject: Re: Checking user session in model
The idea of using session as model is interesting.

On Mar 7, 10:31 am, nate <nate.ab...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
grigri  
View profile  
 More options Mar 10 2008, 7:50 am
From: grigri <j...@hendersonwebdesign.com>
Date: Mon, 10 Mar 2008 04:50:23 -0700 (PDT)
Local: Mon, Mar 10 2008 7:50 am
Subject: Re: Checking user session in model

> The idea of using session as model is interesting.

You mean like this: https://trac.cakephp.org/ticket/1163 ?

Yeah, I agree. Could be very interesting.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google