<?php
-/* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
+/* This file is part of Syj, Copyright (c) 2010-2011 Arnaud Renevier,
and is published under the AGPL license. */
class UserController extends Zend_Controller_Action
{
+ public function existsAction() {
+ $name = $this->getRequest()->getUserParam('name');
+
+ $userMapper = new Syj_Model_UserMapper();
+ $user = new Syj_Model_User();
+
+ if ($userMapper->findByPseudo($name, $user)) {
+ $this->_helper->SyjApi->setCode(200);
+ } else {
+ // opera needs some body content with 404 code, otherwise, it
+ // reports a xmlhttprequest.status of 0
+ $this->_helper->SyjApi->setCode(404)->setBody(' ');
+ }
+ }
+
public function userAction() {
$formData = $this->_helper->SyjPostData->getPostData('Syj_Form_User');
}
}
- $this->_helper->SyjSession->login($user->id);
- $this->_helper->SyjApi->setCode(200);
+ $this->_helper->SyjUserManager->validate($user->pseudo, $user->password);
+
+ $data = array('pseudo' => $user->pseudo);
+ $this->_helper->SyjApi->setBodyJson($data)->setCode(200);
}
}