Hi Amita
Did you check this section of the book?
http://book.cakephp.org/view/392/loginRedirect
On Oct 10, 12:31 pm, amita <[EMAIL PROTECTED]> wrote:
> My application start from one home page where "Sign In" and "Sign Up"
> link is given,
> on clicking sign-in a login form comes and after login it search for
> LoginController.
> In my application login is a part of one "Trainee" model,
> In Trainee model(trainee.php)
> function validateLogin($data)
> {
> $trainee = $this->find(array('email' => $data['email'],
> 'password' => $data['password']), array('id'));
> if(empty($trainee) == false)
> return $trainee['Trainee'];
> return false;
> }
>
> In TraineeController where i have written the code for signup also in
> add() function, wrot code for login like
>
> function beforeFilter()
> {
> $this->__validateLoginStatus();
> }
>
> function __validateLoginStatus()
> {
> if($this->action != 'login' && $this->action != 'logout')
> {
> if($this->Session->check('Trainee') == false)
> {
>
> $this->redirect(array('controller'=>'trainees','action'=>'login'));
>
> $this->Session->setFlash('The URL you\'ve followed
> requires you login.');
> }
> }
> }
>
> function login()
> {
> if(empty($this->data) == false)
> {
> if(($trainee =
> $this->Trainee->validateLogin($this->data['Trainee'])) == true)
>
> {
> $aSession=$this->Session->write('Trainee', $trainee);
> $this->Session->setFlash('You\'ve successfully logged
> in.');
> // $this->redirect('/assign_assignments/index/',
> $aSession);
>
> $this->redirect(array('controller'=>'trainees','action'=>'index'));
>
> }
> else
> {
> $this->Session->setFlash('Sorry, the information you
> \'ve entered is incorrect.');
> }
> }
> }
>
> function add() {
> if (!empty($this->data)) {
> $this->Trainee->create();
> if ($this->Trainee->save($this->data)) {
> $this->Session->setFlash(__('The Trainee has
> been saved', true));
>
> $this->redirect(array('controller'=>'trainees','action'=>'login'));
>
> } else {
> $this->Session->setFlash(__('The Trainee
> could not be saved.
> Please, try again.', true));
> }
> }
> $technologies =
> $this->Trainee->Technology->find('list',array('fields'=>'Technology.technology'));
>
> $this->set(compact('technologies'));
> }
>
> after login it redirect to "http://localhost/cake/logins/login" and
> giving "Error: LoginsController could not be found."
> but i want it will redirect to "http://localhost/cake/assign/index/1"
>
> Please can anybody help me for this.
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---