Subversion Repositories SmartDukaan

Rev

Rev 15070 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 15070 Rev 15405
Line 13... Line 13...
13
 *
13
 *
14
 * @var array
14
 * @var array
15
 */
15
 */
16
	public $components = array('Paginator');
16
	public $components = array('Paginator');
17
 
17
 
-
 
18
	public function beforeFilter() {
-
 
19
        parent::beforeFilter();
-
 
20
        $this->Auth->allow(array('authenticate'));
-
 
21
        }
-
 
22
 
18
/**
23
/**
19
 * index method
24
 * index method
20
 *
25
 *
21
 * @return void
26
 * @return void
22
 */
27
 */
Line 186... Line 191...
186
		} else {
191
		} else {
187
			$this->Session->setFlash(__('The agent could not be deleted. Please, try again.'));
192
			$this->Session->setFlash(__('The agent could not be deleted. Please, try again.'));
188
		}
193
		}
189
		return $this->redirect(array('action' => 'index'));
194
		return $this->redirect(array('action' => 'index'));
190
	}
195
	}
-
 
196
 
191
	public function authenticate(){
197
	public function authenticate(){
192
		$this->log(print_r($this->request->data,1),'authenticatication');
198
		$this->log(print_r($this->request->data,1),'authenticatication');
193
		$this->response->type('json');
199
		if (!$this->Agent->exists($email)) {
194
		$this->layout = 'ajax';
200
			$result = array('success'=>false,'message'=>'Invalid user1');
195
		$this->User->recursive = -1;
201
		}else{
196
		$email=$this->request->data['email'])
202
			$agentEmail = $this->request->data['email'];
197
		$password=$this->request->data['password'])
203
			$agentPassword = $this->request->data['password'];
198
		$role=$this->request->data['role'])
204
			$agentRole = $this->request->data['role'];
-
 
205
			$conditions = array('email'=>$agentEmail,'password'=>$agentPassword);
-
 
206
			$fields = array('id');
-
 
207
			$agentExists = $this->Agent->find('first',array('conditions'=>$conditions,'fields'=>$fields));
-
 
208
			if(empty($agentExists)){
-
 
209
				$result = array('success'=>false,'message'=>'Invalid Role');
-
 
210
			}else{
-
 
211
	       		$this->loadModel('Agent_Role');
-
 
212
	       		$options = array('conditions' => array('id'=> $agentId,'status'=>$agentRole));
-
 
213
				$count = $this->AgentRole->find('count',$options);
-
 
214
		
-
 
215
	       		if(!$count){
-
 
216
					$result = array('success'=>false,'message'=>'Invalid Role');
-
 
217
				}else{
-
 
218
					$result = array('success'=>true,'message'=>'Valid User');
-
 
219
				}
-
 
220
       		}
-
 
221
		}
-
 
222
		$this->set(array(
-
 
223
		    'result' => $result,
-
 
224
		    '_serialize' => array('result')
-
 
225
		)); 
-
 
226
		$this->render('/Elements/json'); 
-
 
227
		
199
	}
228
	}
200
}
229
}