示例#1
0
 public function addUser()
 {
     $result = DB::table('user_table')->insert(['user_id' => $_POST['user_id'], 'user_name' => $_POST['user_name'], 'user_lastname' => $_POST['user_lastname'], 'user_firstname' => $_POST['user_firstname'], 'user_motto' => $_POST['user_motto'], 'email' => $_POST['email'], 'password' => $_POST['password'], 'avatar' => $_POST['avatar'], 'linked_account' => $_POST['linked_account'], 'linked_account_type' => $_POST['linked_account_type'], 'status' => $_POST['status'], 'location' => $_POST['location'], 'background_img' => $_POST['background_img'], 'insert_date' => DB::raw('CURRENT_TIMESTAMP'), 'update_at' => $_POST['update_at']]);
     //此处前台必须添加限制
     $id = $_ENV['STORMPATH_ID'];
     $secret = $_ENV['STORMPATH_SECRET'];
     \Stormpath\Client::$apiKeyProperties = "apiKey.id={$id}\napiKey.secret={$secret}";
     $application = \Stormpath\Resource\Application::get($_ENV['STORMPATH_APPLICATION']);
     $account = \Stormpath\Resource\Account::instantiate(array('givenName' => $_POST['user_firstname'], 'surname' => $_POST['user_lastname'], 'email' => $_POST['email'], 'password' => $_POST['password']));
     $application->createAccount($account);
     return response()->json(['result' => $result]);
 }
 private function registerApplication()
 {
     $this->app->bind('stormpath.application', function () {
         if (config('stormpath.application.href') == null) {
             throw new \InvalidArgumentException('Application href MUST be set.');
         }
         if (!$this->isValidApplicationHref()) {
             throw new \InvalidArgumentException(config('stormpath.application.href') . ' is not a valid Stormpath Application HREF.');
         }
         $application = \Stormpath\Resource\Application::get(config('stormpath.application.href'));
         $this->enhanceConfig($application);
         return $application;
     });
 }
示例#3
0
 public function testGetFromCache()
 {
     $application = self::$application;
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('Another App for Cache', $application->name);
     // Get the application from cache and change the name of it.
     $cache = parent::$client->dataStore->cache;
     $appInCache = $cache->get($application->href);
     $appInCache->name = 'Test';
     $cache->put($application->href, $appInCache, 10);
     // Because the app is already in cache, and we just changed the name... Lets
     // get the application again like normal and see if the name is what we set.
     $application = \Stormpath\Resource\Application::get($application->href);
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertEquals($appInCache->name, $application->name);
     // Now lets delete the cache and see if it is the orig name from the api.
     $cache->delete($application->href);
     $application = \Stormpath\Resource\Application::get($application->href);
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('Another App for Cache', $application->name);
 }
 /**
  * @expectedException \Stormpath\Resource\ResourceError
  */
 public function testDelete()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => 'Yet Another App' . md5(time() . microtime() . uniqid())));
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('Yet Another App', $application->name);
     $href = $application->href;
     $application->delete();
     \Stormpath\Resource\Application::get($href);
 }
 /**
  * @test
  */
 public function it_can_add_an_account_store_mapping()
 {
     $application = \Stormpath\Resource\Application::instantiate(['name' => makeUniqueName('OrgTest'), 'description' => 'Description of Main App', 'status' => 'enabled']);
     $application = self::createResource(\Stormpath\Resource\Application::PATH, $application);
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::instantiate(['organization' => self::$organization, 'accountStore' => self::$directory, 'isDefaultAccountStore' => true, 'isDefaultGroupStore' => true]);
     $test1 = self::$organization->createOrganizationAccountStoreMapping($accountStoreMapping);
     $this->assertInstanceOf('\\Stormpath\\Resource\\AccountStoreMapping', $test1);
     $accountStoreMapping = \Stormpath\Resource\AccountStoreMapping::instantiate(['accountStore' => self::$organization, 'application' => $application, 'isDefaultAccountStore' => true]);
     $test2 = $application->createAccountStoreMapping($accountStoreMapping);
     $this->assertInstanceOf('\\Stormpath\\Resource\\AccountStoreMapping', $test2);
     $org = Organization::get(self::$organization->href);
     $this->assertNotNull($org->accountStoreMappings->href);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStore', $org->defaultAccountStoreMapping);
     $this->assertInstanceOf('Stormpath\\Resource\\AccountStore', $org->defaultGroupStoreMapping);
     $asm = $org->accountStoreMappings;
     foreach ($asm as $mapping) {
         $this->assertEquals($org->href, $mapping->organization->href);
         $this->assertEquals(self::$directory->href, $mapping->accountStore->href);
     }
     $app = Application::get($application->href);
     $this->assertNotNull($app->accountStoreMappings->href);
     $asm = $app->accountStoreMappings;
     foreach ($asm as $mapping) {
         $this->assertEquals($app->href, $mapping->application->href);
         $this->assertEquals(self::$organization->href, $mapping->accountStore->href);
     }
     $application->delete();
 }
示例#6
0
    $url = $application->createIdSiteUrl(['path' => '/#/register', 'callbackUri' => 'http://*****:*****@get_post_by_user');
// *1+.获取一个用户(user_id)发布的所有post详细信息
$app->post('/get_postlist_by_user', 'DataController@get_postlist_by_user');
// *2.从post_id反推出用户id (返回obj) 和所有信息(返回array)
$app->post('/get_userid_by_post', 'DataController@get_userid_by_post');
//*2+.POST获取 Post_id 反推 user详细信息 (return array)
 public function testShouldBeAbleToGetApplicationViaHTMLFragment()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest testFragment')));
     $href = $application->href;
     $hrefParts = array_reverse(explode('/', $href));
     $app = \Stormpath\Resource\Application::get($hrefParts[0]);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app);
     $this->assertEquals($href, $app->href);
     $app2 = \Stormpath\Client::get($hrefParts[1] . '/' . $hrefParts[0], Stormpath::APPLICATION);
     $this->assertInstanceOf('\\Stormpath\\Resource\\Application', $app2);
     $this->assertEquals($href, $app2->href);
     $application->delete();
 }
 private function registerApplication()
 {
     $this->app->singleton('stormpath.application', function () {
         $this->guardAgainstInvalidApplicationHref();
         //            return $this->app['cache.store']->rememberForever('stormpath.application', function() {
         $application = \Stormpath\Resource\Application::get(config('stormpath.application.href'));
         return $application;
         //            });
     });
 }
 /**
  * @expectedException \Stormpath\Resource\ResourceError
  */
 public function testDelete()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest testDelete')));
     $this->assertInstanceOf('Stormpath\\Resource\\Application', $application);
     $this->assertContains('testDelete', $application->name);
     $href = $application->href;
     $application->delete();
     \Stormpath\Resource\Application::get($href);
 }
 /** @test */
 public function an_application_should_allow_setting_authorized_callback_uri()
 {
     $application = \Stormpath\Resource\Application::create(array('name' => makeUniqueName('ApplicationTest authorizedCallbackUri')));
     $application->setAuthorizedCallbackUris(['http://myapplication.com/whatever/callback', 'http://myapplication.com/whatever/callback2']);
     $application->save();
     $application = \Stormpath\Resource\Application::get($application->href);
     $this->assertCount(2, $application->authorizedCallbackUris);
     $application->delete();
 }