Repository URL to install this package:
|
Version:
1.0.0 ▾
|
<?php namespace Modules\Users\Http\Controllers;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Support\Facades\Auth;
use Modules\Core\Http\Controllers\PublicController;
use Modules\Users\Http\Requests\LoginRequest;
use Modules\Users\Http\Requests\RegisterRequest;
class AuthController extends PublicController
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
private $redirectAfterLogout = '/painel/login';
private $loginPath = '/painel/login';
private $redirectTo = '/painel';
private $username = 'email';
public function __construct()
{
parent::__construct();
\Themes::activate(config('core.theme.admin-theme'));
\Asset::add(\Config::get('core.assets.admin-theme'));
// config redirect routes
$this->redirectAfterLogout = localize_url(config('core.admin-prefix') . '/login');
$this->loginPath = localize_url(config('core.admin-prefix') . '/login');
$this->redirectTo = localize_url(config('core.admin-prefix'));
//$this->username = config('users.usernameField', 'username');
}
public function getLogin()
{
return view('users::public.login');
}
public function postLogin(LoginRequest $request)
{
$this->validate($request, [
$this->loginUsername() => 'required', 'password' => 'required',
]);
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
$throttles = $this->isUsingThrottlesLoginsTrait();
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return $this->sendLockoutResponse($request);
}
$credentials = $this->getCredentials($request);
if (Auth::attempt($credentials, $request->has('remember'))) {
return $this->handleUserWasAuthenticated($request, $throttles);
}
// If the login attempt was unsuccessful we will increment the number of attempts
// to login and redirect the user back to the login form. Of course, when this
// user surpasses their maximum number of attempts they will get locked out.
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect($this->loginPath())
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
public function loginPath()
{
return $this->loginPath;
}
public function getRegister()
{
return view('users::public.register');
}
public function postRegister(RegisterRequest $request)
{
//app('Modules\Users\Services\UserRegistration')->register($request->all());
flash()->success(trans('user::messages.account created check email for activation'));
return redirect()->route('register');
}
/*public function getActivate($userId, $code)
{
if (Auth::activate($userId, $code)) {
flash()->success(trans('user::messages.account activated you can now login'));
return redirect()->route('login');
}
flash()->error(trans('user::messages.there was an error with the activation'));
return redirect()->route('register');
}*/
}