plugin updates
This commit is contained in:
@@ -36,8 +36,8 @@ use Socialite;
|
|||||||
*
|
*
|
||||||
* @author Ladybird <info@ladybirdweb.com>
|
* @author Ladybird <info@ladybirdweb.com>
|
||||||
*/
|
*/
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller {
|
||||||
{
|
|
||||||
use AuthenticatesAndRegistersUsers;
|
use AuthenticatesAndRegistersUsers;
|
||||||
/* to redirect after login */
|
/* to redirect after login */
|
||||||
|
|
||||||
@@ -58,15 +58,13 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social)
|
public function __construct(PhpMailController $PhpMailController, SocialMediaController $social) {
|
||||||
{
|
|
||||||
$this->PhpMailController = $PhpMailController;
|
$this->PhpMailController = $PhpMailController;
|
||||||
$social->configService();
|
$social->configService();
|
||||||
$this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]);
|
$this->middleware('guest', ['except' => ['getLogout', 'verifyOTP', 'redirectToProvider']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redirectToProvider($provider, $redirect = '')
|
public function redirectToProvider($provider, $redirect = '') {
|
||||||
{
|
|
||||||
if ($redirect !== '') {
|
if ($redirect !== '') {
|
||||||
$this->setSession($provider, $redirect);
|
$this->setSession($provider, $redirect);
|
||||||
}
|
}
|
||||||
@@ -76,8 +74,7 @@ class AuthController extends Controller
|
|||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleProviderCallback($provider)
|
public function handleProviderCallback($provider) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
//notice we are not doing any validation, you should do it
|
//notice we are not doing any validation, you should do it
|
||||||
$this->changeRedirect();
|
$this->changeRedirect();
|
||||||
@@ -121,8 +118,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function getRegister(CommonSettings $settings)
|
public function getRegister(CommonSettings $settings) {
|
||||||
{
|
|
||||||
// Event for login
|
// Event for login
|
||||||
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
$settings = $settings->select('status')->where('option_name', '=', 'send_otp')->first();
|
||||||
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
$email_mandatory = $settings->select('status')->where('option_name', '=', 'email_mandatory')->first();
|
||||||
@@ -147,8 +143,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function postRegister(User $user, RegisterRequest $request)
|
public function postRegister(User $user, RegisterRequest $request) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
$request_array = $request->input();
|
$request_array = $request->input();
|
||||||
$password = Hash::make($request->input('password'));
|
$password = Hash::make($request->input('password'));
|
||||||
@@ -185,7 +180,7 @@ class AuthController extends Controller
|
|||||||
// Event for login
|
// Event for login
|
||||||
\Event::fire(new \App\Events\LoginEvent($request));
|
\Event::fire(new \App\Events\LoginEvent($request));
|
||||||
if ($request->input('email') !== '') {
|
if ($request->input('email') !== '') {
|
||||||
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/'.$code)]);
|
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => null, 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]);
|
||||||
}
|
}
|
||||||
if ($settings->status == 1 || $settings->status == '1') {
|
if ($settings->status == 1 || $settings->status == '1') {
|
||||||
if (count($sms) > 0) {
|
if (count($sms) > 0) {
|
||||||
@@ -218,8 +213,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type redirect
|
* @return type redirect
|
||||||
*/
|
*/
|
||||||
public function accountActivate($token)
|
public function accountActivate($token) {
|
||||||
{
|
|
||||||
$user = User::where('remember_token', '=', $token)->first();
|
$user = User::where('remember_token', '=', $token)->first();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$user->active = 1;
|
$user->active = 1;
|
||||||
@@ -241,8 +235,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function getMail($token, User $user)
|
public function getMail($token, User $user) {
|
||||||
{
|
|
||||||
$user = $user->where('remember_token', $token)->where('active', 0)->first();
|
$user = $user->where('remember_token', $token)->where('active', 0)->first();
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$user->active = 1;
|
$user->active = 1;
|
||||||
@@ -259,10 +252,9 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function getLogin()
|
public function getLogin() {
|
||||||
{
|
|
||||||
$directory = base_path();
|
$directory = base_path();
|
||||||
if (file_exists($directory.DIRECTORY_SEPARATOR.'.env')) {
|
if (file_exists($directory . DIRECTORY_SEPARATOR . '.env')) {
|
||||||
if (Auth::user()) {
|
if (Auth::user()) {
|
||||||
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
if (Auth::user()->role == 'admin' || Auth::user()->role == 'agent') {
|
||||||
return \Redirect::route('dashboard');
|
return \Redirect::route('dashboard');
|
||||||
@@ -284,8 +276,8 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function postLogin(LoginRequest $request)
|
public function postLogin(LoginRequest $request) {
|
||||||
{
|
try {
|
||||||
// dd($request->input());
|
// dd($request->input());
|
||||||
\Event::fire('auth.login.event', []); //added 5/5/2016
|
\Event::fire('auth.login.event', []); //added 5/5/2016
|
||||||
// Set login attempts and login time
|
// Set login attempts and login time
|
||||||
@@ -315,7 +307,7 @@ class AuthController extends Controller
|
|||||||
'email' => $this->getFailedLoginMessage(),
|
'email' => $this->getFailedLoginMessage(),
|
||||||
'password' => $this->getFailedLoginMessage(),
|
'password' => $this->getFailedLoginMessage(),
|
||||||
])->with(['error' => Lang::get('lang.not-registered'),
|
])->with(['error' => Lang::get('lang.not-registered'),
|
||||||
'referer' => $referer, ]);
|
'referer' => $referer,]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if user exists
|
//if user exists
|
||||||
@@ -338,7 +330,7 @@ class AuthController extends Controller
|
|||||||
'referer' => $referer,
|
'referer' => $referer,
|
||||||
'name' => $check_active->first_name,
|
'name' => $check_active->first_name,
|
||||||
'number' => $check_active->mobile,
|
'number' => $check_active->mobile,
|
||||||
'code' => $check_active->country_code, ]);
|
'code' => $check_active->country_code,]);
|
||||||
} else {
|
} else {
|
||||||
goto a; //attenmpt login (be careful while using goto statements)
|
goto a; //attenmpt login (be careful while using goto statements)
|
||||||
}
|
}
|
||||||
@@ -361,7 +353,7 @@ class AuthController extends Controller
|
|||||||
'email' => $this->getFailedLoginMessage(),
|
'email' => $this->getFailedLoginMessage(),
|
||||||
'password' => $this->getFailedLoginMessage(),
|
'password' => $this->getFailedLoginMessage(),
|
||||||
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
])->with(['error' => Lang::get('lang.this_account_is_currently_inactive'),
|
||||||
'referer' => $referer, ]);
|
'referer' => $referer,]);
|
||||||
} else {
|
} else {
|
||||||
// try login
|
// try login
|
||||||
$loginAttempts = 1;
|
$loginAttempts = 1;
|
||||||
@@ -410,8 +402,11 @@ class AuthController extends Controller
|
|||||||
'email' => $this->getFailedLoginMessage(),
|
'email' => $this->getFailedLoginMessage(),
|
||||||
'password' => $this->getFailedLoginMessage(),
|
'password' => $this->getFailedLoginMessage(),
|
||||||
])->with(['error' => Lang::get('lang.invalid'),
|
])->with(['error' => Lang::get('lang.invalid'),
|
||||||
'referer' => $referer, ]);
|
'referer' => $referer,]);
|
||||||
// Increment login attempts
|
// Increment login attempts
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect()->back()->with('fails', $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -421,8 +416,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function addLoginAttempt($value, $field)
|
public function addLoginAttempt($value, $field) {
|
||||||
{
|
|
||||||
$result = DB::table('login_attempts')->where('IP', '=', $value)->first();
|
$result = DB::table('login_attempts')->where('IP', '=', $value)->first();
|
||||||
$data = $result;
|
$data = $result;
|
||||||
$security = Security::whereId('1')->first();
|
$security = Security::whereId('1')->first();
|
||||||
@@ -449,8 +443,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function clearLoginAttempts($value, $field)
|
public function clearLoginAttempts($value, $field) {
|
||||||
{
|
|
||||||
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
|
$data = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['attempts' => '0']);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -463,14 +456,13 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type Response
|
* @return type Response
|
||||||
*/
|
*/
|
||||||
public function confirmIPAddress($value, $field)
|
public function confirmIPAddress($value, $field) {
|
||||||
{
|
|
||||||
$security = Security::whereId('1')->first();
|
$security = Security::whereId('1')->first();
|
||||||
$time = $security->lockout_period;
|
$time = $security->lockout_period;
|
||||||
$max_attempts = $security->backlist_threshold;
|
$max_attempts = $security->backlist_threshold;
|
||||||
$table = 'login_attempts';
|
$table = 'login_attempts';
|
||||||
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL '.$time.' MINUTE)>NOW() then 1 else 0 end) as Denied '.
|
$result = DB::select('SELECT Attempts, (CASE when LastLogin is not NULL and DATE_ADD(LastLogin, INTERVAL ' . $time . ' MINUTE)>NOW() then 1 else 0 end) as Denied ' .
|
||||||
' FROM '.$table." WHERE IP = '$value' OR User = '$field'");
|
' FROM ' . $table . " WHERE IP = '$value' OR User = '$field'");
|
||||||
$data = $result;
|
$data = $result;
|
||||||
//Verify that at least one login attempt is in database
|
//Verify that at least one login attempt is in database
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
@@ -494,20 +486,18 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @return type string
|
* @return type string
|
||||||
*/
|
*/
|
||||||
protected function getFailedLoginMessage()
|
protected function getFailedLoginMessage() {
|
||||||
{
|
|
||||||
return Lang::get('lang.this_field_do_not_match_our_records');
|
return Lang::get('lang.this_field_do_not_match_our_records');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@category function to show verify OTP page
|
* @category function to show verify OTP page
|
||||||
*
|
*
|
||||||
*@param null
|
* @param null
|
||||||
*
|
*
|
||||||
*@return response|view
|
* @return response|view
|
||||||
*/
|
*/
|
||||||
public function getVerifyOTP()
|
public function getVerifyOTP() {
|
||||||
{
|
|
||||||
if (\Session::has('values')) {
|
if (\Session::has('values')) {
|
||||||
return view('auth.otp-verify');
|
return view('auth.otp-verify');
|
||||||
} else {
|
} else {
|
||||||
@@ -516,14 +506,13 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@category function to verify OTP
|
* @category function to verify OTP
|
||||||
*
|
*
|
||||||
*@param $request
|
* @param $request
|
||||||
*
|
*
|
||||||
*@return int|string
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
public function verifyOTP(LoginRequest $request)
|
public function verifyOTP(LoginRequest $request) {
|
||||||
{
|
|
||||||
$user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))
|
$user = User::select('id', 'mobile', 'user_name')->where('email', '=', $request->input('email'))
|
||||||
->orWhere('user_name', '=', $request->input('email'))->first();
|
->orWhere('user_name', '=', $request->input('email'))->first();
|
||||||
$otp_length = strlen($request->input('otp'));
|
$otp_length = strlen($request->input('otp'));
|
||||||
@@ -568,11 +557,10 @@ class AuthController extends Controller
|
|||||||
->with(['values' => $request->input(),
|
->with(['values' => $request->input(),
|
||||||
'number' => $user->mobile,
|
'number' => $user->mobile,
|
||||||
'name' => $user->user_name,
|
'name' => $user->user_name,
|
||||||
'fails' => $message, ]);
|
'fails' => $message,]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resendOTP(OtpVerifyRequest $request)
|
public function resendOTP(OtpVerifyRequest $request) {
|
||||||
{
|
|
||||||
if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) {
|
if (!\Schema::hasTable('user_verification') || !\Schema::hasTable('sms')) {
|
||||||
$message = Lang::get('lang.opt-can-not-be-verified');
|
$message = Lang::get('lang.opt-can-not-be-verified');
|
||||||
|
|
||||||
@@ -600,8 +588,7 @@ class AuthController extends Controller
|
|||||||
*
|
*
|
||||||
* @author manish.verma@ladybirdweb.com
|
* @author manish.verma@ladybirdweb.com
|
||||||
*/
|
*/
|
||||||
public function openTicketAfterVerification($id)
|
public function openTicketAfterVerification($id) {
|
||||||
{
|
|
||||||
// dd($id);
|
// dd($id);
|
||||||
$ticket = Tickets::select('id')
|
$ticket = Tickets::select('id')
|
||||||
->where(['user_id' => $id, 'status' => 6])
|
->where(['user_id' => $id, 'status' => 6])
|
||||||
@@ -617,18 +604,17 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeRedirect()
|
public function changeRedirect() {
|
||||||
{
|
|
||||||
$provider = \Session::get('provider');
|
$provider = \Session::get('provider');
|
||||||
$url = \Session::get($provider.'redirect');
|
$url = \Session::get($provider . 'redirect');
|
||||||
\Config::set("services.$provider.redirect", $url);
|
\Config::set("services.$provider.redirect", $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSession($provider, $redirect)
|
public function setSession($provider, $redirect) {
|
||||||
{
|
|
||||||
$url = url($redirect);
|
$url = url($redirect);
|
||||||
\Session::set('provider', $provider);
|
\Session::set('provider', $provider);
|
||||||
\Session::set($provider.'redirect', $url);
|
\Session::set($provider . 'redirect', $url);
|
||||||
$this->changeRedirect();
|
$this->changeRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -408,7 +408,7 @@ class SettingsController extends Controller
|
|||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
chmod($app, 0644);
|
chmod($app, 0644);
|
||||||
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
$str = "\n\n\t\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 185;
|
$line_i_am_looking_for = 190;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
@@ -580,7 +580,7 @@ class SettingsController extends Controller
|
|||||||
if (!$plug) {
|
if (!$plug) {
|
||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 185;
|
$line_i_am_looking_for = 190;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
@@ -594,7 +594,7 @@ class SettingsController extends Controller
|
|||||||
|
|
||||||
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
$app = base_path().DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
|
||||||
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
$str = "\n'App\\Plugins\\$slug"."\\ServiceProvider',";
|
||||||
$line_i_am_looking_for = 185;
|
$line_i_am_looking_for = 190;
|
||||||
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
$lines = file($app, FILE_IGNORE_NEW_LINES);
|
||||||
$lines[$line_i_am_looking_for] = $str;
|
$lines[$line_i_am_looking_for] = $str;
|
||||||
file_put_contents($app, implode("\n", $lines));
|
file_put_contents($app, implode("\n", $lines));
|
||||||
|
@@ -188,6 +188,8 @@ return [
|
|||||||
App\FaveoStorage\StorageServiceProvider::class,
|
App\FaveoStorage\StorageServiceProvider::class,
|
||||||
Yajra\Datatables\DatatablesServiceProvider::class,
|
Yajra\Datatables\DatatablesServiceProvider::class,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@@ -310,7 +310,7 @@
|
|||||||
|
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@else
|
||||||
|
|
||||||
<?php \Event::fire('service.desk.agent.sidebar', array()); ?>
|
<?php \Event::fire('service.desk.agent.sidebar', array()); ?>
|
||||||
@endif
|
@endif
|
||||||
|
@@ -166,6 +166,7 @@
|
|||||||
<div class="form-group has-feedback @if(isset($errors)) {!! $errors->has('password') ? 'has-error' : '' !!} @endif">
|
<div class="form-group has-feedback @if(isset($errors)) {!! $errors->has('password') ? 'has-error' : '' !!} @endif">
|
||||||
{!! Form::password('password',['placeholder'=>Lang::get('lang.password'),'class' => 'form-control']) !!}
|
{!! Form::password('password',['placeholder'=>Lang::get('lang.password'),'class' => 'form-control']) !!}
|
||||||
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
|
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
|
||||||
|
<?php \Event::fire('auth.login.form'); ?>
|
||||||
<a href="{{url('password/email')}}" style="font-size: .8em" class="pull-left">{!! Lang::get('lang.forgot_password') !!}</a>
|
<a href="{{url('password/email')}}" style="font-size: .8em" class="pull-left">{!! Lang::get('lang.forgot_password') !!}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group pull-left">
|
<div class="form-group pull-left">
|
||||||
|
Reference in New Issue
Block a user