amend responseHeader
This commit is contained in:
parent
2debb3dc02
commit
a90df3ca74
|
@ -99,8 +99,8 @@ class Authentication
|
||||||
$msg = 'authentication require';
|
$msg = 'authentication require';
|
||||||
$token = $this->authenticator->getToken();
|
$token = $this->authenticator->getToken();
|
||||||
$login = $request->get('login');
|
$login = $request->get('login');
|
||||||
$responseToken = $this->authenticator->generateResponseHeader($token, $login);
|
$responseToken = $this->authenticator->generateResponseHeader($token);
|
||||||
$headers = $this->getResponseHeaders($responseToken);
|
$headers = $this->getResponseHeaders([], $responseToken);
|
||||||
if ($this->authenticator->isValid($token)) {
|
if ($this->authenticator->isValid($token)) {
|
||||||
$password = $request->get('password');
|
$password = $request->get('password');
|
||||||
if ($this->authenticator->check($token, $login)) {
|
if ($this->authenticator->check($token, $login)) {
|
||||||
|
@ -150,7 +150,6 @@ class Authentication
|
||||||
$user->key = $token->getIdent();
|
$user->key = $token->getIdent();
|
||||||
$user->login = $login;
|
$user->login = $login;
|
||||||
$this->session->set('user', $user);
|
$this->session->set('user', $user);
|
||||||
$this->session->set('pwsauth.response', $this->authenticator->generateResponseHeader($token, $login));
|
|
||||||
$this->session->save();
|
$this->session->save();
|
||||||
return $sid;
|
return $sid;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +168,8 @@ class Authentication
|
||||||
$headers = [];
|
$headers = [];
|
||||||
try {
|
try {
|
||||||
$token = $this->authenticator->getToken();
|
$token = $this->authenticator->getToken();
|
||||||
|
$tokenResponse = $this->authenticator->generateResponseHeader($token);
|
||||||
|
$headers = $this->getResponseHeaders($headers, $tokenResponse);
|
||||||
if ($this->authenticator->isValid($token)) {
|
if ($this->authenticator->isValid($token)) {
|
||||||
if (!empty($sid = $this->authenticator->getSessionId($token))) {
|
if (!empty($sid = $this->authenticator->getSessionId($token))) {
|
||||||
$this->sessionInvalidate();
|
$this->sessionInvalidate();
|
||||||
|
@ -178,7 +178,6 @@ class Authentication
|
||||||
$user = $this->session->get('user');
|
$user = $this->session->get('user');
|
||||||
// done : lets controller takes hand
|
// done : lets controller takes hand
|
||||||
if (!is_null($user) && $user->key == $token->getIdent()) {
|
if (!is_null($user) && $user->key == $token->getIdent()) {
|
||||||
$tokenResponse = $this->authenticator->generateResponseHeader($token, $user->login);
|
|
||||||
$this->session->set('pwsauth.response', $tokenResponse);
|
$this->session->set('pwsauth.response', $tokenResponse);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,13 @@ class Controller extends Base
|
||||||
* @param [] $data
|
* @param [] $data
|
||||||
* @return Symfony\Component\HttpFoundation\JsonResponse
|
* @return Symfony\Component\HttpFoundation\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function response($done = false, $msg = "fail", $data = null)
|
public function response($done = false, $msg = "fail", $data = null, $tokenResponse = null)
|
||||||
{
|
{
|
||||||
if (is_null($data)) {
|
if (is_null($data)) {
|
||||||
unset($data);
|
unset($data);
|
||||||
}
|
}
|
||||||
$headers = [];
|
$headers = [];
|
||||||
if (!empty($tokenResponse = $this->session->get('pwsauth.response'))) {
|
if (!empty($tokenResponse) || !empty($tokenResponse = $this->session->get('pwsauth.response'))) {
|
||||||
$headers['Pws-Response'] = $tokenResponse;
|
$headers['Pws-Response'] = $tokenResponse;
|
||||||
}
|
}
|
||||||
$response = new JsonResponse(compact('done', 'msg', 'data'), 200, $headers);
|
$response = new JsonResponse(compact('done', 'msg', 'data'), 200, $headers);
|
||||||
|
@ -107,11 +107,12 @@ class Controller extends Base
|
||||||
*/
|
*/
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
|
$tokenResponse = $this->session->isStarted() ? $this->session->get('pwsauth.response') : null;
|
||||||
$this->handler->sessionInvalidate();
|
$this->handler->sessionInvalidate();
|
||||||
$sessid = $this->session->getId();
|
$sessid = $this->session->getId();
|
||||||
$done = true;
|
$done = true;
|
||||||
$msg = 'session logout';
|
$msg = 'session logout';
|
||||||
return $this->response($done, $msg);
|
return $this->response($done, $msg, null, $tokenResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user