-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
2,800 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
sudo: false | ||
matrix: | ||
include: | ||
- language: php | ||
php: 7.0 | ||
before_script: | ||
- cd api | ||
- travis_retry composer self-update | ||
- travis_retry composer update --no-interaction --prefer-source | ||
script: | ||
- phpunit --coverage-text --coverage-clover=coverage.clover | ||
|
||
- language: node_js | ||
node_js: | ||
- "node" | ||
cache: | ||
yarn: true, | ||
directories: | ||
- node_modules | ||
before_script: | ||
- npm install -g yarn | ||
- cd web-app | ||
- travis_retry yarn install | ||
script: | ||
- yarn build-css | ||
- yarn lint | ||
- travis_retry yarn test | ||
- travis_retry yarn run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class Deploy extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'deploy'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Build and deploy the application'; | ||
|
||
/** | ||
* Create a new command instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
$this->info("DEPLOY APPLICATION\n"); | ||
|
||
$this->exec('cd .. && bash deploy.sh'); | ||
|
||
$this->info("DEPLOYED APPLICATION\n"); | ||
} | ||
|
||
protected function exec($command) | ||
{ | ||
$pwd = base_path(); | ||
|
||
$result = shell_exec("cd $pwd && $command"); | ||
$this->output->write($result); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\User; | ||
use App\Provider; | ||
use Tymon\JWTAuth\Facades\JWTAuth; | ||
use App\Http\Controllers\Controller; | ||
use Laravel\Socialite\Facades\Socialite; | ||
|
||
class AuthSocialiteController extends Controller | ||
{ | ||
private $driver = 'facebook'; | ||
|
||
public function redirectToProvider() | ||
{ | ||
return Socialite::driver($this->driver)->stateless()->redirect(); | ||
} | ||
|
||
public function handleProviderCallback() | ||
{ | ||
$facebookUser = Socialite::driver($this->driver)->stateless()->user(); | ||
|
||
$user = $this->firstOrCreateUser($facebookUser); | ||
|
||
$this->firstOrCreateProvider($user, $facebookUser); | ||
|
||
$token = JWTAuth::fromUser($user); | ||
$redirectUrl = sprintf('%s/login/callback/%s/%s', config('app.url_front_end'), $this->driver, $token); | ||
|
||
return redirect()->to($redirectUrl); | ||
} | ||
|
||
private function firstOrCreateUser($facebookUser) | ||
{ | ||
return User::firstOrCreate(['email' => $facebookUser->email], ['name' => $facebookUser->name]); | ||
} | ||
|
||
private function firstOrCreateProvider($user, $facebookUser) | ||
{ | ||
return Provider::updateOrCreate( | ||
['user_id' => $user->id, 'provider' => $this->driver], | ||
['provider_id' => $facebookUser->id, 'provider_token' => $facebookUser->token] | ||
); | ||
} | ||
} |
Oops, something went wrong.