FusionAuth sendSetPasswordEmail not sending Set Password Email when creating a user - fusionauth

I'm wanting to create a user without specifying the password and have FusionAuth send the Setup Password email. I'm using the PHP client library, and while I can create a user the email is not been sent. However manually dispatching a Reset Password email is delivered successfully.
I've configured the SMTP settings to use my Mailgun account.
Here's what I'm sending via the client;
$this->authClient->createUser(null, [
'user' => [
'active' => true,
'sendSetPasswordEmail' => true,
'birthDate' => '01/01/1990',
'email' => 'a.valid#email.co.uk',
'firstName' => 'John',
'fullName' => 'John Doe',
'lastName' => 'Doe',
'middleName' => '',
'mobilePhone' => +447777777777,
'password' => 'ForSomeReasonThisNEEDStoBeSet',
'data' => [
'identifier' => $someIdentifier
],
'memberships' => [
['groupId' => $myGroupId]
],
'preferredLanguages' => ['en'],
'timezone' => 'Europe/London',
'twoFactorEnabled' => false,
'usernameStatus' => 'ACTIVE',
'username' => $username,
'verified' => true
]
]);
Even when I'm passing the sendSetPasswordEmail the password field is still required, however the docs suggest this shouldn't be the case;
This field is optional only if sendSetPasswordEmail is set to true. By default sendSetPasswordEmail is false, and then this field will be required.
How can I get the Password Setup email to be send when creating a user? Thanks in advance

The sendSetPasswordEmail is a top level value in the JSON request. You need to move it up as a sibling to the user object.
Example:
$this->authClient->createUser(null, [
'sendSetPasswordEmail' => true,
'user' => [
'active' => true,
'birthDate' => '01/01/1990',
'email' => 'a.valid#email.co.uk',
'firstName' => 'John',
'fullName' => 'John Doe',
'lastName' => 'Doe',
'middleName' => '',
'mobilePhone' => +447777777777,
'password' => 'ForSomeReasonThisNEEDStoBeSet',
'data' => [
'identifier' => $someIdentifier
],
'memberships' => [
['groupId' => $myGroupId]
],
'preferredLanguages' => ['en'],
'timezone' => 'Europe/London',
'twoFactorEnabled' => false,
'usernameStatus' => 'ACTIVE',
'username' => $username,
'verified' => true
]
]);
Reference Create User API

Related

Why yii 2 mailer not send email?

My yii 2 web config
'components' => [
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.send-box.ru',
'username' => 'sendbox#jobgis.ru',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
My yii 2 controller for send mail
public function actionSpam(){
Yii::$app->mailer->compose()
->setFrom('sendbox#jobgis.ru')
->setTo('jetananas#yandex.ru')
->setSubject('Тема сообщения')
->setTextBody('Текст сообщения')
->setHtmlBody('<b>текст сообщения в формате HTML</b>')
->send();
}
Why mail not sending?
Why mailer not display errors?

Relation two database and make join yii2

Can you help me. How to relate it and make a join
. i get error has no relation named "project".
i using ActiveRecord with my code :
$posts = MaKantor::find()
->leftJoin('project.track', '`track`.`id_office` = `m_kantor`.`kantor_id`')
->with('project.track')->where(['collecting_id' => $model->collecting_id])
->all();
and config
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=project',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
'db2' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=db_master',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
When you use with('relationName') in query, relation function needs to be defined in MaKantor model.
For example :
public function getProject()
{
return $this->hasOne(Project::className(), ['id' => 'project_id']);
}

How can I edit or extend the error message in laravel5.3?

I want to extend validation setting another field just like that:
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'another_field' => 'validation'
]);
you can make your own validation case by follwing the documentation :)
If you need to change the message only, you can do it by
$messages = [
'required' => 'The :attribute field is required.',
'email' => 'This is a wrong e-mail address message I wrote myself.',
];
$rules = [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'another_field' => 'validation'
];
return Validator::make($input, $rules, $messages);

CakePHP 2 Auth Not Working - Blowfish

I'm using CakePHP 2.8.5. It's not letting me log in "Username or password is incorrect". This seems totally straightforward in the docs but it isn't working for me. I wonder if my model/data structure might be confusing CakePHP. I have a Users model, but the logins are associated with an Admins model. The login form and action are in the Pages model (it has forms for multiple models).
in AppController:
public $components = array(
'DebugKit.Toolbar',
'Flash',
'Session',
'Auth' => array(
'userModel' => 'Admin',
'authenticate' => array(
'Form' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'passwordHasher' => 'Blowfish'
)
),
'loginAction' => array(
'controller' => 'pages',
'action' => 'login',
),
'logoutRedirect' => array(
'controller' => 'pages',
'action' => 'login',
),
'authError' => 'Please log in',
'authorize' => array('Controller')
)
);
My login view, in /View/Pages. "email" is the username field:
<?php
echo $this->Form->create('Admin');
echo $this->Form->input('email');
echo $this->Form->input('password');
echo $this->Form->end('Submit');
?>
PagesController:
public function login() {
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Flash->error(__('Username or password is incorrect'));
}
}}
Top of Admin model:
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
Automatic Blowfish encryption in Admin model:
public function beforeSave($options = array()) {
if (isset($this->data['Admin']['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data['Admin']['password'] = $passwordHasher->hash(
$this->data['Admin']['password']
);
}
return true;
}
I notice if I enter the same password for different Admins, I get a different encryption result, but I've read that's normal.
If you want to see anything else, I'll add it.
The userModel key is in the wrong place
Compare the config in the question:
public $components = array(
'DebugKit.Toolbar',
'Flash',
'Session',
'Auth' => array(
'userModel' => 'Admin',
'authenticate' => array(
'Form' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'passwordHasher' => 'Blowfish'
)
),
To the config in the docs:
$this->Auth->authenticate = array(
'Basic' => array('userModel' => 'Member'),
'Form' => array('userModel' => 'Member')
);
In the question userModel is a top-level key, in the docs it is part of the individual authenticate keys. Looking at the api examples (or the doc blocks in the source code) the error is more clear:
... you can define settings that should be set to all authentications objects using the 'all' key:
$this->Auth->authenticate = array(
'all' => array(
'userModel' => 'Users.User',
'scope' => array('User.active' => 1)
),
'Form',
'Basic'
);
It is possible to define a global userModel for all authenticate objects to use, but the syntax is simply different than the question.
Use the all key
Therefore to define a user model to use for all authenticate options, use the all key:
public $components = array(
'DebugKit.Toolbar',
'Flash',
'Session',
'Auth' => array(
//'userModel' => 'Admin', // <- no
'authenticate' => array(
'all' => array(
'userModel' => 'Admin' // <- yes
),
'Form' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'passwordHasher' => 'Blowfish'
)
),

install.php is not being run during installation

My install.php is not being run during installation.I checked everywhere.To be sure,I ran the code in install.php elsewhere and it worked well. But during installation only the install.php is being skipped somehow.My module name is Hotelreservation, hence the code in install.php is as below. Why is there no error display during installation ?
<?php
class Hotelreservation_Installer extends Engine_Package_Installer_Module
{
public function onInstall()
{
$this->_hotelroomsBrowsePage();
parent::onInstall();
}
protected function _hotelroomsBrowsePage()
{
$db = $this->getDb();
// profile page
$page_id = $db->select()
->from('engine4_core_pages', 'page_id')
->where('name = ?', 'hotelreservation_index_browse')
->limit(1)
->query()
->fetchColumn();
if (!$page_id) {
// Insert page
$db->insert('engine4_core_pages', array(
'name' => 'hotelreservation_index_browse',
'displayname' => 'HotelRooms Browse Page',
'title' => 'Browse Rooms',
'description' => 'this page displays rooms',
'custom' => 0,
));
$page_id = $db->lastInsertId();
// Insert main
$db->insert('engine4_core_content', array(
'type' => 'container',
'name' => 'main',
'page_id' => $page_id,
));
$main_id = $db->lastInsertId();
// Insert middle
$db->insert('engine4_core_content', array(
'type' => 'container',
'name' => 'middle',
'page_id' => $page_id,
'parent_content_id' => $main_id,
'order' => 2,
));
$middle_id = $db->lastInsertId();
// Insert hotelreservation.browse-menu
$db->insert('engine4_core_content', array(
'type' => 'widget',
'name' => 'hotelreservation.browse-menu',
'page_id' => $page_id,
'parent_content_id' => $middle_id,
'order' => 1,
));
// Insert core content
$db->insert('engine4_core_content', array(
'type' => 'widget',
'name' => 'core.content',
'page_id' => $page_id,
'parent_content_id' => $middle_id,
'order' => 2,
));
// Insert left
$db->insert('engine4_core_content', array(
'type' => 'container',
'name' => 'left',
'page_id' => $page_id,
'parent_content_id' => $main_id,
'order' => 3,
));
$left_id = $db->lastInsertId();
}
return $this;
}
}// end class
Did you add info to mainfest file like this in packages array
'callback' => array(
'path' => 'Your path to php file',
'class' => 'Hotelreservation_Installer',
),
I agree with Arif. Check the file manifest.php inside of //settings:
(info of module Album)
'callback' => array(
'path' => 'application/modules/Album/settings/install.php',
'class' => 'Album_Installer',
),
I had this same issue and got it to work.
It turns out that the installer looks in application/packages/module-yourmodule-x.x.x.json first. around line 35 you'll find:
"callback": {
"path": null,
"class": "Engine_Package_Installer_Module",
"priority": 100
},
change that to:
"callback": {
"path": "application/modules/Yourmodule/settings/install.php",
"class": "Yourmodule_Installer",
"priority": 100
},
now, when you run the installer, your install.php will be called.