update v1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-15 15:27:05 +05:30
parent e753fcd221
commit 7a66ae9307
2 changed files with 31 additions and 44 deletions

View File

@@ -580,8 +580,7 @@ INSERT INTO `workflow_close` (`id`, `days`, `condition`, `send_email`, `status`,
-- --
-- Alter Table structure for table `system_settings` -- Alter Table structure for table `system_settings`
-- --
ALTER TABLE `settings_system` ALTER TABLE `settings_system` ADD `version` varchar(222) NOT NULL AFTER `time_zone`;
ADD `version` varchar(222) NOT NULL AFTER `time_zone`;
-- --
-- Dumping data for table `system_settings` -- Dumping data for table `system_settings`
@@ -590,8 +589,11 @@ ALTER TABLE `settings_system`
UPDATE `settings_system` SET `version`='1.0.7.5' WHERE 1 UPDATE `settings_system` SET `version`='1.0.7.5' WHERE 1
ALTER TABLE `settings_ticket` ALTER TABLE `settings_ticket` ADD `lock_ticket_frequency` varchar(222) NOT NULL AFTER `max_file_size`;
ADD `lock_ticket_frequency` varchar(222) NOT NULL AFTER `max_file_size`;
UPDATE `settings_ticket` SET `lock_ticket_frequency`='0' WHERE 1 UPDATE `settings_ticket` SET `lock_ticket_frequency`='0' WHERE 1
TRUNCATE TABLE `user_notification`;
TRUNCATE TABLE `notifications`;

View File

@@ -29,8 +29,8 @@ use Mail;
* *
* @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 */
@@ -50,8 +50,7 @@ class AuthController extends Controller
* *
* @return void * @return void
*/ */
public function __construct(PhpMailController $PhpMailController) public function __construct(PhpMailController $PhpMailController) {
{
$this->PhpMailController = $PhpMailController; $this->PhpMailController = $PhpMailController;
SettingsController::smtp(); SettingsController::smtp();
$this->middleware('guest', ['except' => 'getLogout']); $this->middleware('guest', ['except' => 'getLogout']);
@@ -62,8 +61,7 @@ class AuthController extends Controller
* *
* @return type Response * @return type Response
*/ */
public function getRegister() public function getRegister() {
{
// Event for login // Event for login
\Event::fire(new \App\Events\FormRegisterEvent()); \Event::fire(new \App\Events\FormRegisterEvent());
if (Auth::user()) { if (Auth::user()) {
@@ -85,8 +83,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) {
{
// Event for login // Event for login
\Event::fire(new \App\Events\LoginEvent($request)); \Event::fire(new \App\Events\LoginEvent($request));
$password = Hash::make($request->input('password')); $password = Hash::make($request->input('password'));
@@ -99,34 +96,28 @@ class AuthController extends Controller
$code = str_random(60); $code = str_random(60);
$user->remember_token = $code; $user->remember_token = $code;
$user->save(); $user->save();
$message12 = ''; $message12 = "";
$var = $this->PhpMailController->sendmail($from = $this->PhpMailController->mailfrom('1', '0'), $to = ['name' => $name, 'email' => $request->input('email')], $message = ['subject' => 'Activate your Account', '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' => 'Activate your Account', 'scenario' => 'registration'], $template_variables = ['user' => $name, 'email_address' => $request->input('email'), 'password_reset_link' => url('account/activate/' . $code)]);
if ($var == null) { if ($var == null) {
$message12 = Lang::get('lang.failed_to_send_email_contact_administrator'); $message12 = Lang::get('lang.failed_to_send_email_contact_administrator');
return redirect('home')->with('warning', $message12); return redirect('home')->with('warning', $message12);
} else { } else {
$message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail'); $message12 = Lang::get('lang.activate_your_account_click_on_Link_that_send_to_your_mail');
} }
return redirect('home')->with('success', $message12); return redirect('home')->with('success', $message12);
} }
/** /**
* Function to activate account. * Function to activate account
*
* @param type $token * @param type $token
*
* @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;
$user->remember_token = null; $user->remember_token = NULL;
$user->save(); $user->save();
return redirect('/auth/login')->with('status', 'Acount activated. Login to start'); return redirect('/auth/login')->with('status', 'Acount activated. Login to start');
} else { } else {
return redirect('/auth/login')->with('fails', 'Invalid Token'); return redirect('/auth/login')->with('fails', 'Invalid Token');
@@ -141,8 +132,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;
@@ -159,8 +149,7 @@ class AuthController extends Controller
* *
* @return type Response * @return type Response
*/ */
public function getLogin() public function getLogin() {
{
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');
@@ -179,8 +168,7 @@ class AuthController extends Controller
* *
* @return type Response * @return type Response
*/ */
public function postLogin(LoginRequest $request) public function postLogin(LoginRequest $request) {
{
// Set login attempts and login time // Set login attempts and login time
$value = $_SERVER['REMOTE_ADDR']; $value = $_SERVER['REMOTE_ADDR'];
$usernameinput = $request->input('email'); $usernameinput = $request->input('email');
@@ -199,7 +187,7 @@ class AuthController extends Controller
return redirect()->back() return redirect()->back()
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
'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'));
} }
@@ -207,7 +195,7 @@ class AuthController extends Controller
return redirect()->back() return redirect()->back()
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
'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'));
} }
@@ -250,7 +238,7 @@ class AuthController extends Controller
return redirect()->back() return redirect()->back()
->withInput($request->only('email', 'remember')) ->withInput($request->only('email', 'remember'))
->withErrors([ ->withErrors([
'email' => $this->getFailedLoginMessage(), 'email' => $this->getFailedLoginMessage(),
'password' => $this->getFailedLoginMessage(), 'password' => $this->getFailedLoginMessage(),
])->with('error', Lang::get('lang.invalid')); ])->with('error', Lang::get('lang.invalid'));
// Increment login attempts // Increment login attempts
@@ -263,8 +251,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();
@@ -272,13 +259,13 @@ class AuthController extends Controller
if ($data) { if ($data) {
$attempts = $data->Attempts + 1; $attempts = $data->Attempts + 1;
if ($attempts == $apt) { if ($attempts == $apt) {
$result = DB::select('UPDATE login_attempts SET Attempts='.$attempts.", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'"); $result = DB::update('UPDATE login_attempts SET Attempts=' . $attempts . ", LastLogin=NOW() WHERE IP = '$value' OR User = '$field'");
} else { } else {
$result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts]); $result = DB::table('login_attempts')->where('IP', '=', $value)->orWhere('User', '=', $field)->update(['Attempts' => $attempts]);
// $result = DB::select("UPDATE login_attempts SET Attempts=".$attempts." WHERE IP = '$value' OR User = '$field'"); // $result = DB::select("UPDATE login_attempts SET Attempts=".$attempts." WHERE IP = '$value' OR User = '$field'");
} }
} else { } else {
$result = DB::select("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())"); $result = DB::insert("INSERT INTO login_attempts (Attempts,User,IP,LastLogin) values (1,'$field','$value', NOW())");
} }
} }
@@ -289,8 +276,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;
@@ -303,14 +289,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) {
@@ -334,8 +319,8 @@ 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');
} }
} }