diff --git a/app/Console/Commands/CreateAccount.php b/app/Console/Commands/CreateAccount.php index 053b7661400b..1ac58a241519 100644 --- a/app/Console/Commands/CreateAccount.php +++ b/app/Console/Commands/CreateAccount.php @@ -105,6 +105,9 @@ class CreateAccount extends Command 'password' => Hash::make($password), 'confirmation_code' => $this->createDbHash(config('database.default')), 'email_verified_at' => now(), + 'first_name' => 'New', + 'last_name' => 'User', + 'phone' => '', ]); $company_token = new CompanyToken; diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index 44f384b86526..c85600a18de8 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -169,4 +169,27 @@ abstract class QueryFilters return $this->builder->where('created_at', '>=', $created_at); } + + public function is_deleted($value) + { + + return $this->builder->where('is_deleted', $value); + + } + + public function filter_deleted_clients($value) + { + + if($value == 'true'){ + + return $this->builder->whereHas('client', function (Builder $query) { + + $query->where('is_deleted', 0); + + }); + + } + + return $this->builder; + } } diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 10036a77bda7..04284731398b 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -104,7 +104,7 @@ class ForgotPasswordController extends Controller */ public function sendResetLinkEmail(Request $request) { - MultiDB::userFindAndSetDb($request->input('email')); + // MultiDB::userFindAndSetDb($request->input('email')); // $user = MultiDB::hasUser(['email' => $request->input('email')]); @@ -115,9 +115,13 @@ class ForgotPasswordController extends Controller // need to show to the user. Finally, we'll send out a proper response. $response = $this->broker()->sendResetLink( $this->credentials($request) - ); + ); if ($request->ajax()) { + + if($response == Password::RESET_THROTTLED) + return response()->json(['message' => ctrans('passwords.throttled'), 'status' => false], 429); + return $response == Password::RESET_LINK_SENT ? response()->json(['message' => 'Reset link sent to your email.', 'status' => true], 201) : response()->json(['message' => 'Email not found', 'status' => false], 401); diff --git a/app/Http/Middleware/SetEmailDb.php b/app/Http/Middleware/SetEmailDb.php index 8a977d0f30a8..5a5c8c290a86 100644 --- a/app/Http/Middleware/SetEmailDb.php +++ b/app/Http/Middleware/SetEmailDb.php @@ -34,15 +34,10 @@ class SetEmailDb if ($request->input('email') && config('ninja.db.multi_db_enabled')) { - if (! MultiDB::userFindAndSetDb($request->input('email'))) return response()->json($error, 400); - } - // else { - // return response()->json($error, 403); - // } return $next($request); } diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index f9206969fd8b..2c48291dbd53 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -457,13 +457,13 @@ class CompanyExport implements ShouldQueue fclose($tempStream); - $nmo = new NinjaMailerObject; - $nmo->mailable = new DownloadBackup(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company); - $nmo->to_user = $this->user; - $nmo->settings = $this->company->settings; - $nmo->company = $this->company; + // $nmo = new NinjaMailerObject; + // $nmo->mailable = new DownloadBackup(Storage::disk(config('filesystems.default'))->url($path.$file_name), $this->company); + // $nmo->to_user = $this->user; + // $nmo->settings = $this->company->settings; + // $nmo->company = $this->company; - NinjaMailerJob::dispatch($nmo); + // NinjaMailerJob::dispatch($nmo); UnlinkFile::dispatch(config('filesystems.default'), $path.$file_name)->delay(now()->addHours(1)); } diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index 27673891e09f..d2ff11741f96 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -188,12 +188,15 @@ class MultiDB //multi-db active foreach (self::$dbs as $db) { - if (User::on($db)->where(['email' => $email])->count() >= 1) + if (User::on($db)->where('email', $email)->count() >= 1){ + nlog("setting db {$db}"); + self::setDb($db); return true; - - } - self::setDefaultDatabase(); + } + } + + self::setDefaultDatabase(); return false; } diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index e5544d201665..114cc03b88d0 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -18,5 +18,6 @@ return [ 'sent' => 'We have e-mailed your password reset link!', 'token' => 'This password reset token is invalid.', 'user' => "We can't find a user with that e-mail address.", + 'throttled' => "You have requested password reset recently, please check your email.", ]; diff --git a/routes/api.php b/routes/api.php index b46bd12f0d2e..74b994c693c3 100644 --- a/routes/api.php +++ b/routes/api.php @@ -18,7 +18,7 @@ Route::group(['middleware' => ['api_secret_check']], function () { Route::post('api/v1/oauth_login', 'Auth\LoginController@oauthApiLogin'); }); -Route::group(['middleware' => ['api_secret_check', 'email_db']], function () { +Route::group(['middleware' => ['api_secret_check','email_db']], function () { Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit'); Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail'); }); diff --git a/tests/Feature/Export/ExportCompanyTest.php b/tests/Feature/Export/ExportCompanyTest.php index bfdad43e3845..c30e85417a0e 100644 --- a/tests/Feature/Export/ExportCompanyTest.php +++ b/tests/Feature/Export/ExportCompanyTest.php @@ -45,5 +45,7 @@ class ExportCompanyTest extends TestCase public function testCompanyExport() { CompanyExport::dispatchNow($this->company, $this->company->users->first()); + + $this->assertTrue(true); } }