mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
commit
6734660751
@ -14,6 +14,6 @@
|
|||||||
"visiosoft/addblock-extension": "^1.1",
|
"visiosoft/addblock-extension": "^1.1",
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"chumper/zipper": "^1.0",
|
"chumper/zipper": "^1.0",
|
||||||
"sentry/sentry-laravel": "*"
|
"sentry/sentry-laravel": "2.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Command;
|
||||||
|
|
||||||
|
use Anomaly\UsersModule\Role\Contract\RoleRepositoryInterface;
|
||||||
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
|
use Anomaly\UsersModule\User\UserActivator;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class AuthAuto
|
||||||
|
{
|
||||||
|
protected $token;
|
||||||
|
|
||||||
|
public function __construct($token)
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,6 +6,7 @@ use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterf
|
|||||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
|
use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use Illuminate\Contracts\Container\Container;
|
use Illuminate\Contracts\Container\Container;
|
||||||
@ -13,10 +14,13 @@ use Illuminate\Contracts\Events\Dispatcher;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Redirect;
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Visiosoft\ProfileModule\Command\AuthAuto;
|
||||||
use Visiosoft\ProfileModule\Profile\ProfileRepository;
|
use Visiosoft\ProfileModule\Profile\ProfileRepository;
|
||||||
|
|
||||||
class UserAuthenticator
|
class UserAuthenticator
|
||||||
{
|
{
|
||||||
|
use DispatchesJobs;
|
||||||
|
|
||||||
protected $guard;
|
protected $guard;
|
||||||
protected $events;
|
protected $events;
|
||||||
protected $container;
|
protected $container;
|
||||||
@ -124,4 +128,12 @@ class UserAuthenticator
|
|||||||
return response()->json(['userExists' => false]);
|
return response()->json(['userExists' => false]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function authAuto()
|
||||||
|
{
|
||||||
|
if (\request()->has(['token'])) {
|
||||||
|
$this->dispatch(new AuthAuto(\request('token')));
|
||||||
|
}
|
||||||
|
return \redirect('/');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,6 +79,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
// UserAuthenticator
|
// UserAuthenticator
|
||||||
'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt',
|
'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt',
|
||||||
'ajax/phone-validation' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@phoneValidation',
|
'ajax/phone-validation' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@phoneValidation',
|
||||||
|
'auth-auto' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@authAuto',
|
||||||
|
|
||||||
// RegisterController
|
// RegisterController
|
||||||
'register' => [
|
'register' => [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user