mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-27 22:54:05 +08:00
Nescio support + NewUser command
This commit is contained in:
parent
c5be1462df
commit
7c436a9bca
@ -64,4 +64,10 @@ MAIL_HOST=localhost
|
|||||||
MAIL_PORT=1025
|
MAIL_PORT=1025
|
||||||
MAIL_USERNAME=null
|
MAIL_USERNAME=null
|
||||||
MAIL_PASSWORD=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
|
||||||
|
48
app/Console/Commands/NewUser.php
Normal file
48
app/Console/Commands/NewUser.php
Normal 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)),
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
|
|||||||
\BookStack\Console\Commands\Inspire::class,
|
\BookStack\Console\Commands\Inspire::class,
|
||||||
\BookStack\Console\Commands\ResetViews::class,
|
\BookStack\Console\Commands\ResetViews::class,
|
||||||
\BookStack\Console\Commands\RegeneratePermissions::class,
|
\BookStack\Console\Commands\RegeneratePermissions::class,
|
||||||
|
\BookStack\Console\Commands\NewUser::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
protected $listen = [
|
protected $listen = [
|
||||||
SocialiteWasCalled::class => [
|
SocialiteWasCalled::class => [
|
||||||
'SocialiteProviders\Slack\SlackExtendSocialite@handle',
|
'SocialiteProviders\Slack\SlackExtendSocialite@handle',
|
||||||
|
'\Nescio\Socialite\Handler@handle'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use BookStack\Exceptions\SocialSignInException;
|
|||||||
use BookStack\Exceptions\UserRegistrationException;
|
use BookStack\Exceptions\UserRegistrationException;
|
||||||
use BookStack\Repos\UserRepo;
|
use BookStack\Repos\UserRepo;
|
||||||
use BookStack\SocialAccount;
|
use BookStack\SocialAccount;
|
||||||
|
use BookStack\User;
|
||||||
|
|
||||||
class SocialAuthService
|
class SocialAuthService
|
||||||
{
|
{
|
||||||
@ -14,7 +15,7 @@ class SocialAuthService
|
|||||||
protected $socialite;
|
protected $socialite;
|
||||||
protected $socialAccount;
|
protected $socialAccount;
|
||||||
|
|
||||||
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter'];
|
protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'nescio'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SocialAuthService constructor.
|
* SocialAuthService constructor.
|
||||||
@ -106,6 +107,15 @@ class SocialAuthService
|
|||||||
if (!$isLoggedIn && $socialAccount !== null) {
|
if (!$isLoggedIn && $socialAccount !== null) {
|
||||||
return $this->logUserIn($socialAccount->user);
|
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,
|
// 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.
|
// Create the social account and attach it to the user & redirect to the profile page.
|
||||||
|
9
composer.json
Normal file → Executable file
9
composer.json
Normal file → Executable file
@ -4,6 +4,12 @@
|
|||||||
"keywords": ["BookStack", "Documentation"],
|
"keywords": ["BookStack", "Documentation"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
|
"repositories": [{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://github.com/arietimmerman/socialite-provider-nescio"
|
||||||
|
}],
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.6.4",
|
"php": ">=5.6.4",
|
||||||
"laravel/framework": "5.4.*",
|
"laravel/framework": "5.4.*",
|
||||||
@ -18,7 +24,8 @@
|
|||||||
"gathercontent/htmldiff": "^0.2.1",
|
"gathercontent/htmldiff": "^0.2.1",
|
||||||
"barryvdh/laravel-snappy": "^0.3.1",
|
"barryvdh/laravel-snappy": "^0.3.1",
|
||||||
"laravel/browser-kit-testing": "^1.0",
|
"laravel/browser-kit-testing": "^1.0",
|
||||||
"socialiteproviders/slack": "^3.0"
|
"socialiteproviders/slack": "^3.0",
|
||||||
|
"arietimmerman/socialite-provider-nescio": "dev-master"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
|
387
composer.lock
generated
387
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -50,6 +50,14 @@ return [
|
|||||||
'redirect' => env('APP_URL') . '/login/service/google/callback',
|
'redirect' => env('APP_URL') . '/login/service/google/callback',
|
||||||
'name' => 'Google',
|
'name' => 'Google',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'nescio' => [
|
||||||
|
'client_id' => 'NOTUSED',
|
||||||
|
'client_secret' => 'NOTUSED',
|
||||||
|
'redirect' => 'NOTUSED',
|
||||||
|
'name' => 'Nescio',
|
||||||
|
'baseurl' => 'https://asdgasdgdsag.nl'
|
||||||
|
],
|
||||||
|
|
||||||
'slack' => [
|
'slack' => [
|
||||||
'client_id' => env('SLACK_APP_ID', false),
|
'client_id' => env('SLACK_APP_ID', false),
|
||||||
|
1
resources/assets/icons/nescio.svg
Normal file
1
resources/assets/icons/nescio.svg
Normal 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 |
@ -176,4 +176,8 @@ Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail
|
|||||||
|
|
||||||
// Password reset routes...
|
// Password reset routes...
|
||||||
Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
|
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");
|
||||||
|
// });
|
Loading…
x
Reference in New Issue
Block a user