Example #1
0
 public function loggedIn()
 {
     $session = Session::get('snowfire', []);
     if ($session) {
         $app = \Snowfire\App\Storage\AccountStorage::whereAppKey($session['app_key'])->first();
         $session['app'] = $app;
     }
     return $session;
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     AccountStorage::create(['app_key' => md5(time()), 'site_url' => 'http://example.com', 'state' => 'INSTALLED']);
 }
Example #3
0
 Route::post('/accept', ['as' => 'snowfire.accept', function () {
     $storage = \Snowfire\App\Storage\AccountStorage::where('site_url', '=', Request::get('domain'))->first();
     // Create new app, or activate a previously uninstalled app from the same domain
     if ($storage == null) {
         $storage = new \Snowfire\App\Storage\AccountStorage();
         $storage->site_url = Request::get('domain');
     }
     $storage->app_key = Request::get('appKey');
     $storage->state = 'INSTALLED';
     $storage->save();
     //Log::info('sfapp/accept', [$_GET, $_POST]);
     return Response::make(Snowfire::response(true), 200, ['content-type' => 'text/xml']);
 }]);
 Route::post('/uninstall', ['as' => 'snowfire.uninstall', function () {
     //Log::info('sfapp/uninstall', [$_GET, $_POST]);
     $account = \Snowfire\App\Storage\AccountStorage::whereAppKey(Request::get('appKey'))->first();
     $account->state = 'UNINSTALLED';
     $account->save();
     return Response::make(Snowfire::response(true), 200, ['content-type' => 'text/xml']);
 }]);
 // Admin tab
 Route::get('/tab-proxy', ['as' => 'snowfire.tab', function () {
     $accountsRepository = app('Snowfire\\App\\Repositories\\AccountsRepository');
     $appKey = Request::get('snowfireAppKey');
     $app = $accountsRepository->getByKey($appKey);
     if (!$app) {
         return Response::make('Invalid Snowfire app key', 403);
     }
     Snowfire::login(Request::get('snowfireAppKey'), Request::get('snowfireUserKey'));
     return Redirect::route(Snowfire::parameter('tabRedirectRoute'), [$app->id]);
 }]);
 public function getByKey($key)
 {
     return AccountStorage::whereAppKey($key)->first();
 }