FreeSwitch - It doesn't connect MySQL database using xml_mod_curl - freeswitch

After install FreeSwitch, I tried to connect user account using xml_mod_curl. I followed below instruction to connect MySQL database.
http://saevolgo.blogspot.kr/2012/07/freeswitch-with-sip-users-in-mysql-mod.html
I could see that it actually read XML to sign in SIP account with 1000-1019 username. However, it doesn't look like it connects MySQL database. I failed to sign in new user and new password that is saved in MySQL column.
here is global_defines.php
if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) {
header('Location: index.php');
}
/**
* Defines the default dsn for the FS_PDO class
*/
define('DEFAULT_DSN', 'mysql:dbname=FS_DB;host=127.0.0.1');
/**
* Defines the default dsn login for the PDO class
*/
define('DEFAULT_DSN_LOGIN', 'root');
/**
* Defines the default dsn password for the PDOclass
*/
define('DEFAULT_DSN_PASSWORD', 'mypassword');
/**
* Generic return success
*/
define('FS_CURL_SUCCESS', 0);
/**
* Generic return success
*/
define('FS_SQL_SUCCESS', '00000');
/**
* Generic return warning
*/
define('FS_CURL_WARNING', 1);
/**
* Generic return critical
*/
define('FS_CURL_CRITICAL', 2);
/**
* determines how the error handler handles warnings
*/
define('RETURN_ON_WARN', true);
/**
* Determines whether or not users should be domain specific
* If GLOBAL_USERS is true, user info will be returned for whatever
* domain is passed.....
* NOTE: using a1 hashes will NOT work with this setting
*/
define('GLOBAL_USERS', false);
The instruction article was written 2 years ago. It seems like there should be one more option to turn on My-SQL connection. Did I missing something?

Related

How can I "validate" DELETE request in api-platform

I want to check the entity variable and check if it is allowed to delete the entity. For example if the owner entity of the association is linked to another entity, I want to make the deletion impossible.
I've looked in the documentation of api-platform bu I could not find any help regarding my problems. Either you give the right to delete or not. I could not find how to control it (equivalent to validation for POST, PUT and PATCH).
You can use the access control feature of Api-Platform and Symfony Expression Language to achieve what you want. This way you can write pretty complex expressions.
I hope this example makes it clear.
user is the currently logged in user.
object is the resource user is trying to delete.
/**
* #ApiResource(
* itemOperations={
* "delete"={
* "access_control"="is_granted('ROLE_USER') and object.getUsers().contains(user),
* }
* }
* )
*/
class Entity
{
/**
* #var ArrayCollection
*
* #ORM\OneToMany(targetEntity="User", inversedBy="entities")
* #ORM\JoinTable(name="entity_users")
*/
private $users;
/**
* #return ArrayCollection
*/
public function getUsers(): ArrayCollection
{
return $this->users;
}
}
In this case only users who are stored in users Array of Entity can delete this resource.

Overriding property name in Api Platform

Oke, so I have the following use case. On some of my entities I use a file entity for example with the organization logo.
Now I want users to post either a link (I will then async get the file) or a base64 has of the file. But when the user does a get I want to present an JSON representation of the file entity (that also includes size, a thumbnail link etc).
The current setup that I have is two different properties on my entity, one for reading and one for posting with different logic. And then an event listener that handels the logic. That’s all fine and all but it causes the user to post a postLogo property in their json file, I would hower like them to post to a logo property in their json file.
Is there an annotation that I can use (for example name on ApiProperty) to achieve this or do I need to override the serializer?
/**
* #var File The logo of this organisation
*
* #ORM\ManyToOne(targetEntity="File")
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="#/components/schemas/File"
* }
* }
* )
* #Groups({"read"})
*/
public $logo;
/**
* #var string The logo of this organisation, a logo can iether be posted as a valid url to that logo or a base64 reprecentation of that logo.
*
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="url or base64"
* }
* }
* )
* #Groups({"write"})
*/
public $postLogo;
You can add a setter with a SerializedName annotation. Something like this should work
/**
* #Groups({"write"})
* #SerializedName("logo")
*
*/
public function setPostLogo($value)
{
$this->postLogo = $value;
}

Joomla! 3.xx *onUserLogout* event not working

I have successfully implemented the onUserAuthenticate event to implement my custom authentication API inside the Joomla! site that I am working on.
Now I want to also have some custom code run on the onUserLogout event.
I have added the following code to the custom authentication plugin file.
But this method is not getting fired/invoked while the previous one(onUserAuthenticate) is working just fine.
/**
* Method to handle the SSO logout
*
* #param array $user Holds the user data.
* #param array $options Array holding options (client, ...).
*
* #return boolean Always returns true.
*
* #since 1.6
*/
public function onUserLogout($user, $options = array()) {
if (JFactory::getApplication()->isSite()) {
// Set the cookie to expired date.
setcookie('customAuth', '123', time() - (60 * 60 * 24 * 365), '/', '.customdomain.org');
}
return true;
}
Okay so I was getting it all wrong.
So I was adding the aforementioned method inside the same plugin file that handled the onUserAuthenticate.
For Joomla! the login is a separate process which has its respective events like onUserAuthenticate.
But it seems like the event onUserLogout has to be inside the plugin with the type of user.
So I created a separate plugin inside the user plugin type directory, installed it, and enabled it....And voila!! it worked.
This had me scratching my head for quite a while.

Symfony 2 - Set UniqueEntity message

I have a Symfony 2/Doctrine 2 entity with a UniqueEntity constraint. As show in the documentation, it should be possible to set a custom error message. I tied the following syntax, but that dose not work:
/**
* #ORM\Entity
* #ORM\Table(name="User")
* #UniqueEntity("email", message="Your E-Mail adress has already been registered")
*/
class User
What is the correct notation for the UniqueEntity constraint message? Or is the documentation simply wrong?
If you use only fields option in this annotaion, it can be used as the default option (the only option without name). However when you specify additional settings, you have to specify fields property.
/**
* #ORM\Entity
* #ORM\Table(name="User")
* #UniqueEntity(
* fields={"email"},
* message="Your E-Mail adress has already been registered"
* )
*/
class User

Change the customer password field Magento

Can anybody explain how magento customer login works.
In fact, I have a bit weird situation. I need to copy all the customer from existing website to new magento website (I want my customers to use the same username password to login to new website). I know how the passwords have been encrypted in the old website (using normal php encrypt() function with salt) but I can't decrypt them. So I thought of adding a new field in customer account called 'oldpassword' (I followed this blog to create new field in customer account).
What I want now is, when importing the customers, save the old encrypted passwords in 'oldpassword' field. When customer tries to login, it should match the password with oldpassword field using the old encryption method. If password, matches, it should generate the standard magento password and save that in default password field. So next time when customer tries to log in, it should check if default password field is not empty, then just login normally.
ADDED
Still waiting for help
I have overwritten the customer->advanceContoller but not quite sure what changes to make in loginPostAction.
Please go to page: app/code/core/Mage/Customer/Model/Customer.php
You can see function public function authenticate($login, $password)
Also you can see
/**
* Validate password with salted hash
*
* #param string $password
* #return boolean
*/
public function validatePassword($password)
{
if (!($hash = $this->getPasswordHash())) {
return false;
}
return Mage::helper('core')->validateHash($password, $hash);
}
/**
* Encrypt password
*
* #param string $password
* #return string
*/
public function encryptPassword($password)
{
return Mage::helper('core')->encrypt($password);
}
/**
* Decrypt password
*
* #param string $password
* #return string
*/
public function decryptPassword($password)
{
return Mage::helper('core')->decrypt($password);
}
Please check this file.

Resources