Monday, November 29, 2010

Login from external service

Hi
I'm new to CakePhp. So far it's been a great framework, but now I've
run into a bit of a snag.
The web app that we're working on has a client front end which is
completely separate from cakePhp (Currently using the Qooxdoo
library). The client and server comunicate using json and named
parameters, and for the most part it works great. The only thing that
I can't get working from the client is the login. I've tried to adapt
what's shown in the tutorials, but I think that I don't understand
Cake well enough yet.

I'm trying to take the username and password from the URL, and send it
to the Auth component. It fills what I send in to the fields, but it
doesn't actually log me in.

Thank you for your help
Alex

Here is what I have so far:

Url:
localhost/server/users/login/username:name/password:pass

Controller:
<?php
class UsersController extends AppController
{
var $name = 'User';


function beforeFilter()
{
$this->Auth->allow('*');

if(isSet($this->passedArgs['username']))
{
$this->data['User']['username'] = $this->passedArgs['username'];
}
if(isSet($this->passedArgs['password']))
{
$this->data['User']['password'] = $this->passedArgs['password'];
}
}

function login(){
}


function logout()
{
$this->redirect($this->Auth->logout());
}
}


View:
<h1>Log in</h1>
<?=$form->create('User',array('action'=>'login'));?>
<?=$form->input('username');?>
<?=$form->input('password', array('type'=>'password'));?>
<?=$form->end('login');?>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

CakePlate - Boilerplate CakePHP distro

You know how as a developer each time you create a new web app you
spend the first few hours downloading, installing, and configuring the
important add-ons that you need for nearly any production-level
project? When all you really want to do is get started on your new
kick-ass idea?

That's why a friend and I decided to do something about it. We're
launching CakePlate, a open source distribution of CakePHP that's
ready to rock, right out of the box.

learn more and read the full announcement at http://cakeplate.posterous.com/

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

great, thx for the prompt help! I would of course read the entire docs
(later), but your quick help is very helpful for a beginner like me.

On Tue, Nov 30, 2010 at 9:23 AM, cricket <zijn.digital@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 5:43 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
>> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
>> blog. When I add validation to my model, I got this error:
>>
>> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
>> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>>
>>
>> Here's my model:
>> <?php
>> class Blog extends AppModel {
>>        var $name = 'Blog';
>>        var $validate = array(
>>                        'title' => array(
>>                                        'rule' => VALID_NOT_EMPTY,
>>                                        'message' => 'Title of a blog cannot be empty'
>>                        )
>>        );
>> }
>> ?>
>>
>> Any idea what this error is all about? Thx for any help.
>
> Yes, it's an undefined constant. VALID_NOT_EMPTY was deprecated awhile
> back. Use 'rule' => 'notEmpty' instead.
>
> http://book.cakephp.org/view/1143/Data-Validation
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: Error : VALID_NOT_EMPTY

On Mon, Nov 29, 2010 at 5:43 AM, Hans Wiriya Tsai <hansw.id@gmail.com> wrote:
> I hv CakePHP 1.3.6 installed on Ubuntu and learning to create simple
> blog. When I add validation to my model, I got this error:
>
> Notice (8): Use of undefined constant VALID_NOT_EMPTY - assumed
> 'VALID_NOT_EMPTY' [CORE/cake/libs/class_registry.php, line 141]
>
>
> Here's my model:
> <?php
> class Blog extends AppModel {
>        var $name = 'Blog';
>        var $validate = array(
>                        'title' => array(
>                                        'rule' => VALID_NOT_EMPTY,
>                                        'message' => 'Title of a blog cannot be empty'
>                        )
>        );
> }
> ?>
>
> Any idea what this error is all about? Thx for any help.

Yes, it's an undefined constant. VALID_NOT_EMPTY was deprecated awhile
back. Use 'rule' => 'notEmpty' instead.

http://book.cakephp.org/view/1143/Data-Validation

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: RequestHandler::isAjax() buggy?

On Sun, Nov 28, 2010 at 10:57 PM, Dr. Loboto <drloboto@gmail.com> wrote:
> Check that request is really done. I never saw this in anything except
> IE, but in IE it is always aggressive caching when browser do not
> repeat request to the same URL in the short period of time at all. If
> you see same (no real request) in other browsers it is definitely
> aggressive caching by headers of your app or your web server.

What's weird is i was seeing it in 3 separate browsers. I didn't check
IE because I was stressed enough without having to boot Windows, as
well (it kind of always gives me the creeps :-) That's why i assumed
it must be server-side. Unfortunately, my stress level made me jump to
conclusions about isAjax(). (And, yes, I'm pretty embarrassed about
that) So I next wondered about Apache. Except nothing's been changed
there recently.

In the end, the bug disappeared. I was making repeated requests with
Firebug's Net tab open. Nothing. A Heisenbug, perhaps. I don't know
what I might have done to fix the problem. I did dump the cache, but I
was seeing the problem after that. Then ... no more bug. I hate that,
because I don't know if/when it's going to appear again.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: How to create private messaging system in cakephp or scrapbook application in cakephp??

did you try to google it - or at least to look for previous questions
for that matter
the above search box combined with "messaging" reveals:

http://groups.google.com/group/cake-php/browse_thread/thread/65390b32b859c47/d747c576100ed6c4?lnk=gst&q=messaging#d747c576100ed6c4
and many more

On 29 Nov., 12:03, vk1985 <vinaya.kulkarn...@gmail.com> wrote:
> Hi,
>
> I am new to cakephp.
> i want to create a scrapbook like application for my social network
> project.
> so please if anybody having some examples then post here.
> i am in need.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

Re: RequestHandler::isAjax() buggy?

Hi, maytbe this will halp you to find your bug.

I have add into app_controller before_filter() this lines

$this->disableCache();
I've found this solution in http://osdir.com/ml/CakePHP/2010-01/msg00629.html
(for view this link content - look into google cache, now it forbidden
for me :( )


On Nov 29, 5:57 am, "Dr. Loboto" <drlob...@gmail.com> wrote:
> Check that request is really done. I never saw this in anything except
> IE, but in IE it is always aggressive caching when browser do not
> repeat request to the same URL in the short period of time at all. If
> you see same (no real request) in other browsers it is definitely
> aggressive caching by headers of your app or your web server.
>
> On 29 ноя, 02:34, cricket <zijn.digi...@gmail.com> wrote:
>
> > On Sun, Nov 28, 2010 at 2:56 PM, cricket <zijn.digi...@gmail.com> wrote:
> > > I'm seeing some strange behavior on a site. I haven't been able to
> > > reproduce it locally, just on the server, and it's also only showing
> > > up just once in a while. What's happening is, occasionally, isAjax()
> > > is incorrectly returning true, and so just the element is rendered.
>
> > > public function index()
> > > {
> > >        $this->Session->write('path_back', $this->here);
>
> > >        $this->set('data', $this->paginate());
>
> > >        if ($this->RequestHandler->isAjax())
> > >        {
> > >                $this->viewPath = 'elements'.DS.'books';
> > >                $this->render('pagination');
> > >        }
> > > }
>
> > > So, I've got  a paginated list of books, and I'm loading further pages
> > > using AJAX. The session business allows me to get back to the correct
> > > index page from a "view" view. I can't think of any reason why that
> > > would be involved, though.
>
> > > I can't remember seeing anyone else report this sort of thing. Has
> > > anyone run into it? Or have any suggestions for why this might be
> > > occurring? Or how to go about debugging this?
>
> > Sorry for the noise. This fell into my lap while I was busily trying
> > to get something else to deadline and I wasn't thinking things through
> > very well. It's not a Cake issue, although I'll continue here as it
> > might be of help to someone someday.
>
> > The obvious first step is to log the request headers before rendering
> > just the element. I did that and see:
>
> > [X-Requested-With] => XMLHttpRequest
>
> > So Cake is doing the right thing. Next step: check the browser. I was
> > using FF 3.6.12. I could see that the page is being refreshed but
> > tried disabling JS anyway. Sure enough, I was able to eventually
> > repeat it. I then opened the site in Chrome (7.0.517.44) and clicked
> > away for a while (remember, this bug only shows up occasionally). I
> > was literally just about to give up on Chrome when the bug showed
> > itself. I then was able to get Opera (10.10) to do it.
>
> > I disabled caching, on the principle that it couldn't hurt, so why
> > not? No difference.
>
> > Speaking of caching: Firefox is showing this un-styled rendered
> > element, and I try shift-refresh. After four or five tries, the page
> > finally loads correctly. WTF? This makes no sense at all.
>
> > Maybe an Apache bug? That's beginning to seem like the only
> > explanation. Especially as everything's fine locally. Will update that
> > and post results.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en