Hi All,
I have created a web service in Symfony 1.4 to log in users to the
system by sending 'multipart/form-data' and returning JSON response.
My requirement is that it should accept multipart/form-data and return
a JSON response. When I test the service from the browser, it works
fine, however, when my iPhone Developers test the same service, they
do not succeed. When I had checked the log, the username and password
fields were empty. Though, they too were sending multipart/form-data.
What am I doing wrong here ?
if($request->getContentType()=='multipart/form-data')
{
$username = $request->getParameter('username');
$password = $request->getParameter('password');
$q = Doctrine_Query::create()
->select('*')
->from('User u')
->where('u.username="'.$username.'"')
->andWhere('deleted_at is null');
$user = $q->fetchone();
if($user['username']=='' || $user['username']==NULL)
{
$ret_msg = "Username does not exist";
$return_code = 1;
}
if(($user['is_activated'] == '0') && ($username != NULL))
{
$ret_msg = "Please check your e-mail to activate your
account";
$return_code = 2;
}
if( ($user['is_activated'] == '1') && ($password != null) &&
($username != null))
{
if(encrypter::comparePwds($password, $user['password']))
{
$this->getUser()->setInSession($user);
$return_code = 4;
}
else
{
$ret_msg = "Please enter correct password";
$return_code = 3;
}
}
if($return_code==4)
{
$tojsonize=array("id"=>$user['id']);
}
else
{
$tojsonize=array("message"=>$ret_msg);
}
$this->getResponse()->setHttpHeader('Content-type', 'application/
json');
$this->renderText(json_encode($tojsonize,true));
return sfView::NONE;
}
I have also created a form to test the service from the browser and it
returns correct messag in JSON format:
<form method="post" action="/api/test" enctype="multipart/form-
data">
<input name="username" type="text" />
<input name="password" type="password" />
<input name="submit" type="submit" value="submit" />
</form>
Why can't it get the username and password values from the app
request ?
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" 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/symfony-devs?hl=en