public function validateAccount($provider, $reference, $token)
{
try {
$result = $this->SocialAccounts->validateAccount($provider, $reference, $token);
if ($result) {
$this->Flash->success(__d('CakeDC/Users', 'Account validated successfully'));
} else {
$this->Flash->error(__d('CakeDC/Users', 'Account could not be validated'));
}
} catch (RecordNotFoundException $exception) {
$this->Flash->error(__d('CakeDC/Users', 'Invalid token and/or social account'));
} catch (AccountAlreadyActiveException $exception) {
$this->Flash->error(__d('CakeDC/Users', 'Social Account already active'));
} catch (Exception $exception) {
$this->Flash->error(__d('CakeDC/Users', 'Social Account could not be validated'));
}
return $this->redirect(['plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login']);
}