Nescio support + NewUser command

This commit is contained in:
Arie Timmerman 2017-02-17 22:36:23 +01:00
parent c5be1462df
commit 7c436a9bca
10 changed files with 304 additions and 177 deletions

View File

@ -64,4 +64,10 @@ MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_ENCRYPTION=null
NESCIO_APP_ID=APPID
NESCIO_KEY=1
NESCIO_SECRET=SECRET
NESCIO_REDIRECT_URI=https://wiki.deverbindinghilversum.nl/login/service/nescio/callback
NESCIO_BASEURL=https://mijn.deverbindinghilversum.nl

View File

@ -0,0 +1,48 @@
<?php
namespace BookStack\Console\Commands;
use Illuminate\Console\Command;
use BookStack\User;
class NewUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'newuser {name} {email} {avatar}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new user';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle() {
User::create([
'name' => $this->argument('name'),
'email' => $this->argument('email'),
'password' => bcrypt(str_random(40)),
]);
}
}

View File

@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
\BookStack\Console\Commands\Inspire::class,
\BookStack\Console\Commands\ResetViews::class,
\BookStack\Console\Commands\RegeneratePermissions::class,
\BookStack\Console\Commands\NewUser::class,
];
/**

View File

@ -16,6 +16,7 @@ class EventServiceProvider extends ServiceProvider
protected $listen = [
SocialiteWasCalled::class => [
'SocialiteProviders\Slack\SlackExtendSocialite@handle',
'\Nescio\Socialite\Handler@handle'
],
];

View File

@ -6,6 +6,7 @@ use BookStack\Exceptions\SocialSignInException;
use BookStack\Exceptions\UserRegistrationException;
use BookStack\Repos\UserRepo;
use BookStack\SocialAccount;
use BookStack\User;
class SocialAuthService
{
@ -14,7 +15,7 @@ class SocialAuthService
protected $socialite;
protected $socialAccount;
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter'];
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'nescio'];
/**
* SocialAuthService constructor.
@ -106,6 +107,15 @@ class SocialAuthService
if (!$isLoggedIn && $socialAccount !== null) {
return $this->logUserIn($socialAccount->user);
}
$user = User::where("email",$socialId)->first();
if(!$isLoggedIn && $user){
$this->fillSocialAccount($socialDriver, $socialUser);
$user->socialAccounts()->save($this->socialAccount);
return $this->logUserIn($user);
}
// When a user is logged in but the social account does not exist,
// Create the social account and attach it to the user & redirect to the profile page.

9
composer.json Normal file → Executable file
View File

@ -4,6 +4,12 @@
"keywords": ["BookStack", "Documentation"],
"license": "MIT",
"type": "project",
"repositories": [{
"type": "vcs",
"url": "https://github.com/arietimmerman/socialite-provider-nescio"
}],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
@ -18,7 +24,8 @@
"gathercontent/htmldiff": "^0.2.1",
"barryvdh/laravel-snappy": "^0.3.1",
"laravel/browser-kit-testing": "^1.0",
"socialiteproviders/slack": "^3.0"
"socialiteproviders/slack": "^3.0",
"arietimmerman/socialite-provider-nescio": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

387
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -50,6 +50,14 @@ return [
'redirect' => env('APP_URL') . '/login/service/google/callback',
'name' => 'Google',
],
'nescio' => [
'client_id' => 'NOTUSED',
'client_secret' => 'NOTUSED',
'redirect' => 'NOTUSED',
'name' => 'Nescio',
'baseurl' => 'https://asdgasdgdsag.nl'
],
'slack' => [
'client_id' => env('SLACK_APP_ID', false),

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 266.893 266.895"><path fill="#3C5A99" d="M248.082 262.307c7.854 0 14.223-6.37 14.223-14.225V18.812c0-7.857-6.368-14.224-14.223-14.224H18.812c-7.857 0-14.224 6.367-14.224 14.224v229.27c0 7.855 6.366 14.225 14.224 14.225h229.27z"/><path fill="#FFF" d="M182.41 262.307v-99.803h33.498l5.016-38.895H182.41V98.775c0-11.26 3.126-18.935 19.274-18.935l20.596-.01V45.047c-3.562-.474-15.788-1.533-30.012-1.533-29.695 0-50.025 18.126-50.025 51.413v28.684h-33.585v38.894h33.585v99.803h40.166z"/></svg>

After

Width:  |  Height:  |  Size: 541 B

View File

@ -176,4 +176,8 @@ Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail
// Password reset routes...
Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
// Route::get('/settings/users/{id}', function(){
// die("asdgasd");
// });