User management and Brand tenant
composer require phuocdaivl/sts-sdk
Add the service provider to the providers array in the config/app.php
config file as follows:
'providers' => [
...
DaiDP\StsSDK\Providers\StsServiceProvider::class,
]
Well done.
Basic use:
$umSDK = app()->get(\DaiDP\StsSDK\UserManagement\UserManagementInterface::class);
The following methods are available on the UserManagement instance.
Create new account
$data = [
'username' => '0766808284',
'fullname' => 'Phước Đại',
'email' => '[email protected]',
'password' => '12345678',
'confirmpassword' => '12345678'
];
$result = $umSDK->register($data);
Set new password for account
$phone = '0766808284';
$password = 'abc123ABC';
$result = $umSDK->resetPassword($phone, $password);
Basic use:
$tmSDK = app()->get(\DaiDP\StsSDK\TenantManagement\TenantManagementInterface::class);
The following methods are available on the TenantManagement instance.
Create new database tenant
$name = 'tenant001';
$result = $tmSDK->createTenant($name);
Create new database connection of tenant
$idTenant = 'f06e16bc-1035-4de3-93cc-96bdd21da4a5';
$connectionString = 'Server=localhost;port=3306;Database=tenant_01;user=root;password=';
$result = $tmSDK->createConnectionString($idTenant, $connectionString);
Get database connection string list
$serviceName = 'RetailProBrand';
$result = $tmSDK->getConnectionStrings($serviceName);
Basic use:
$sysuSDK = app()->get(\DaiDP\StsSDK\SystemUserManagement\SystemUserManagementInterface::class);
The following methods are available on the SystemUserManagement instance.
Create new account
$data = [
'email' => '[email protected]',
'fullname' => 'Phước Đại',
'password' => '12345678',
'confirmpassword' => '12345678'
];
$result = $sysuSDK->register($data);
Set new password for account
$email = '[email protected]';
$password = 'abc123ABC';
$result = $sysuSDK->resetPassword($email, $password);
Change account password
$email = '[email protected]';
$oldPassword = '12345678';
$newPassword = 'abc123ABC';
$result = $sysuSDK->changePassword($email, $oldPassword, $newPassword);
Basic use:
$tumSDK = app()->get(\DaiDP\StsSDK\TenantUserManagement\TenantUserManagementInterface::class);
$tumSDK->setTenantId('f06e16bc-1035-4de3-93cc-96bdd21da4a5'); // required
The following methods are available on the TenantUserManagement instance.
Create new account
$data = [
'username' => 'usertn001',
'email' => '[email protected]',
'fullname' => 'Phước Đại',
'password' => '12345678',
'confirmpassword' => '12345678'
];
$result = $tumSDK->register($data);
Set new password for account
$username = 'usertn001';
$password = 'abc123ABC';
$result = $tumSDK->resetPassword($username, $password);
Change account password
$username = 'usertn001';
$oldPassword = '12345678';
$newPassword = 'abc123ABC';
$result = $tumSDK->changePassword($username, $oldPassword, $newPassword);