68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
include_once APPPATH.'/vendor/autoload.php';
|
|
|
|
use Aws\CognitoIdentityProvider\CognitoIdentityProviderClient;
|
|
//use Aws\Exception\AwsException;
|
|
|
|
class AWS_COGNITO
|
|
{
|
|
private $client;
|
|
private $name = "TEST";
|
|
private $CI;
|
|
private $cognito_properties;
|
|
public function __construct()
|
|
{
|
|
// Construct the parent class
|
|
//parent::__construct();
|
|
|
|
$this->CI =& get_instance();
|
|
$this->cognito_properties = array('region'=>'ap-south-1','version'=>'latest','credentials' => array(
|
|
'key' =>$this->CI->config->item('cognito_resource_key'),
|
|
'secret' => $this->CI->config->item('cognito_resource_secret')
|
|
));
|
|
$this->client = CognitoIdentityProviderClient::factory($this->cognito_properties);
|
|
// echo "Called";
|
|
// $this->setCors('lender8');die();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function adminResetPassword($user_name)
|
|
{
|
|
$result = $this->client->adminResetUserPassword([
|
|
'UserPoolId' => $this->CI->config->item('sine_egde_pool_id'), // REQUIRED
|
|
'Username' => $user_name, // REQUIRED
|
|
]);
|
|
print_r($result);
|
|
}
|
|
|
|
|
|
public function adminSetUserPassword($user_name)
|
|
{
|
|
//print_r('adminSetUserPassword');
|
|
$result = $this->client->adminSetUserPassword([
|
|
'Password' => 'temp1234', // REQUIRED
|
|
'Permanent' => false,
|
|
'UserPoolId' => $this->CI->config->item('sine_egde_pool_id'), // REQUIRED
|
|
'Username' => $user_name, // REQUIRED
|
|
]);
|
|
print_r($result);
|
|
}
|
|
|
|
//duplicated of adminSetUserPassword because otp generation on restapi
|
|
public function resetUserPassword($user_name,$key)
|
|
{
|
|
$result = $this->client->adminSetUserPassword([
|
|
'Password' => 'temp1234', // REQUIRED
|
|
'Permanent' => false,
|
|
'UserPoolId' => $this->CI->config->item($key), // REQUIRED
|
|
'Username' => $user_name, // REQUIRED
|
|
]);
|
|
}
|
|
}
|
|
|
|
?>
|