phuocdaivl / sts-sdk
User management and Brand tenant
Requires
- guzzlehttp/guzzle: ^6.3
README
User management and Brand tenant
Download & Install
composer require phuocdaivl/sts-sdk
Add service provider
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.
User management
Basic use:
$umSDK = app()->get(\DaiDP\StsSDK\UserManagement\UserManagementInterface::class);
Methods
The following methods are available on the UserManagement instance.
register()
Create new account
$data = [ 'username' => '0766808284', 'fullname' => 'Phước Đại', 'email' => '0766808284@gmail.com', 'password' => '12345678', 'confirmpassword' => '12345678' ]; $result = $umSDK->register($data);
resetPassword()
Set new password for account
$phone = '0766808284'; $password = 'abc123ABC'; $result = $umSDK->resetPassword($phone, $password);
Tenant management
Basic use:
$tmSDK = app()->get(\DaiDP\StsSDK\TenantManagement\TenantManagementInterface::class);
Methods
The following methods are available on the TenantManagement instance.
createTenant()
Create new database tenant
$name = 'tenant001'; $result = $tmSDK->createTenant($name);
createConnectionString()
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);
getConnectionStrings()
Get database connection string list
$serviceName = 'RetailProBrand'; $result = $tmSDK->getConnectionStrings($serviceName);
System user management
Basic use:
$sysuSDK = app()->get(\DaiDP\StsSDK\SystemUserManagement\SystemUserManagementInterface::class);
Methods
The following methods are available on the SystemUserManagement instance.
register()
Create new account
$data = [ 'email' => 'admin001@gmail.com', 'fullname' => 'Phước Đại', 'password' => '12345678', 'confirmpassword' => '12345678' ]; $result = $sysuSDK->register($data);
resetPassword()
Set new password for account
$email = 'admin001@gmail.com'; $password = 'abc123ABC'; $result = $sysuSDK->resetPassword($email, $password);
changePassword()
Change account password
$email = 'admin001@gmail.com'; $oldPassword = '12345678'; $newPassword = 'abc123ABC'; $result = $sysuSDK->changePassword($email, $oldPassword, $newPassword);
Tenant user management
Basic use:
$tumSDK = app()->get(\DaiDP\StsSDK\TenantUserManagement\TenantUserManagementInterface::class); $tumSDK->setTenantId('f06e16bc-1035-4de3-93cc-96bdd21da4a5'); // required
Methods
The following methods are available on the TenantUserManagement instance.
register()
Create new account
$data = [ 'username' => 'usertn001', 'email' => 'usertn001@gmail.com', 'fullname' => 'Phước Đại', 'password' => '12345678', 'confirmpassword' => '12345678' ]; $result = $tumSDK->register($data);
resetPassword()
Set new password for account
$username = 'usertn001'; $password = 'abc123ABC'; $result = $tumSDK->resetPassword($username, $password);
changePassword()
Change account password
$username = 'usertn001'; $oldPassword = '12345678'; $newPassword = 'abc123ABC'; $result = $tumSDK->changePassword($username, $oldPassword, $newPassword);