#15435 - Saving user version on singup

This commit is contained in:
Christophe LATOUR 2018-01-16 15:42:18 +01:00
parent b3644c8735
commit 37f0f717d4
5 changed files with 32 additions and 0 deletions

View File

@ -30,6 +30,27 @@ class User extends BaseCustomer implements WsseUser
return $model; return $model;
} }
/**
* Save customer version in DB
*
* @param string $version
*
* @return boolean Whether operation succeed
*/
public function saveVersion($version = null) {
if ($version === null) {
$version = config('api.defaultVersion');
}
return \Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'customer_version`
VALUES (
'.(int) $this->id.',
"'.pSQL(!isset($version) ? 'fr': $version).'",
NOW()
)
');
}
/** /**
* @see Antadis\Auth\Wsse\Contracts\WsseUser::getWssePassword() * @see Antadis\Auth\Wsse\Contracts\WsseUser::getWssePassword()
*/ */

View File

@ -7,6 +7,7 @@ use Antadis\API\Front\Web\Controllers\AuthController as BaseAuthController;
use Antadis\API\Front\Exceptions\HttpBadRequestException; use Antadis\API\Front\Exceptions\HttpBadRequestException;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use ApiValidate;
use ApiCart; use ApiCart;
class AuthController extends BaseAuthController class AuthController extends BaseAuthController
@ -45,10 +46,17 @@ class AuthController extends BaseAuthController
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @Override #15435 - Saving user version
*/ */
public function signup(Request $request) public function signup(Request $request)
{ {
$user = parent::signup($request); $user = parent::signup($request);
if (ApiValidate::isLoadedObject($user)) {
$user->saveVersion();
}
return $user; return $user;
} }

View File

@ -18,4 +18,5 @@ return array(
], ],
], ],
'id_cms_ant_support' => array(14), 'id_cms_ant_support' => array(14),
'defaultVersion' => 'fr',
); );

View File

@ -18,4 +18,5 @@ return array(
], ],
], ],
'id_cms_ant_support' => array(14), 'id_cms_ant_support' => array(14),
'defaultVersion' => 'fr',
); );

View File

@ -18,4 +18,5 @@ return array(
], ],
], ],
'id_cms_ant_support' => array(14), 'id_cms_ant_support' => array(14),
'defaultVersion' => 'fr',
); );