Guest User

Untitled

a guest
Jun 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function signin($username='', $password='') {
  2. if (isset($username) && isset($password)) {
  3. $customer = $this->Customer->find('first', array('conditions' => array('Customer.customers_username' => $username)));
  4. if (!empty($customer['Customer']['customers_id']) && $customer['Customer']['customers_password'] == md5($password)) {
  5. $data = array('Customer' => array('username' => $username, 'password' => $password));
  6. $this->Auth->login($data);
  7. $sessionInfo = $this->Session->read();
  8. $output = array(
  9. 'loginResponse' => array(
  10. 'sessionID' => $sessionInfo['Config']['userAgent']
  11. )
  12. );
  13. } else {
  14. $output = array(
  15. 'error' => array(
  16. 'errorCode' => 'INVALID_LOGIN',
  17. 'description' => 'Invalid username or password'
  18. )
  19. );
  20. }
  21. $this->set('output',$output);
  22. }
  23.  
  24. }
Add Comment
Please, Sign In to add comment