diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 59d0dc8e01b4..131fdaa3d177 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -10,6 +10,8 @@ use Event; use Validator; use stdClass; +use App\Models\User; +use App\Models\Activity; use App\Models\Account; use App\Models\Country; use App\Models\Currency; @@ -688,9 +690,8 @@ class AccountController extends BaseController $user->email = trim(strtolower(Input::get('new_email'))); $user->username = $user->email; $user->password = trim(Input::get('new_password')); - $user->password_confirmation = trim(Input::get('new_password')); $user->registered = true; - $user->amend(); + $user->save(); if (Utils::isNinja()) { $this->userMailer->sendConfirmation($user); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index f52144178cd3..8fbc5b2211b3 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -9,6 +9,7 @@ use Cache; use Redirect; use DB; use Event; +use URL; use App\Models\Invoice; use App\Models\Invitation; diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index f7a3f8f652ed..369b1200271e 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -227,7 +227,7 @@ class UserController extends BaseController $user->email = trim(Input::get('email')); $user->registered = true; $user->password = str_random(RANDOM_KEY_LENGTH); - $user->password_confirmation = $user->password; + $user->confirmation_code = str_random(RANDOM_KEY_LENGTH); $user->public_id = $lastUser->public_id + 1; } @@ -257,83 +257,20 @@ class UserController extends BaseController return Redirect::to('company/advanced_settings/user_management'); } - /** - * Displays the login form - * - */ - /* - public function login() - { - - // Auth::login(\App\Models\User::first()); // Debug purposes only - // Show Login | If not already logged in - if (!Confide::user()) { - return View::make(Config::get('confide.login_form')); - } - - // Show Dashboard | If user is logged in - Event::fire('user.login'); - Session::reflash(); - - return Redirect::to('/dashboard'); - } - */ - - /** - * Attempt to do login - * - */ - /* - public function do_login() - { - $input = array( - 'email' => Input::get('login_email'), // May be the username too - 'username' => Input::get('login_email'), // so we have to pass both - 'password' => Input::get('login_password'), - 'remember' => true, - ); - - // If you wish to only allow login from confirmed users, call logAttempt - // with the second parameter as true. - // logAttempt will check if the 'email' perhaps is the username. - // Get the value from the config file instead of changing the controller - // dd(Confide::logAttempt($input, false)); - if (Input::get('login_email') && Confide::logAttempt($input, false)) { - Event::fire('user.login'); - // Redirect the user to the URL they were trying to access before - // caught by the authentication filter IE Redirect::guest('user/login'). - // Otherwise fallback to '/' - // Fix pull #145 - return Redirect::intended('/dashboard'); // change it to '/admin', '/dashboard' or something - } else { - - // Set Error Message - $err_msg = trans('texts.security.wrong_credentials'); - - // Check if there was too many login attempts - if (Confide::isThrottled($input)) { - $err_msg = trans('texts.security.too_many_attempts'); - } - - return Redirect::action('UserController@login') - ->withInput(Input::except('login_password')) - ->with('error', $err_msg); - } - } - */ /** * Attempt to confirm account with code * * @param string $code */ - /* public function confirm($code) { - if (Confide::confirm($code)) { + $user = User::where('confirmation_code', '=', $code)->get()->first(); + + if ($user) { $notice_msg = trans('texts.security.confirmation'); - $user = User::where('confirmation_code', '=', $code)->get()->first(); + $user->confirmed = true; $user->confirmation_code = ''; $user->save(); @@ -348,104 +285,15 @@ class UserController extends BaseController return Redirect::to($invitation->getLink()); } else { - return Redirect::action('UserController@login')->with('message', $notice_msg); + return Redirect::to(Auth::check() ? '/dashboard' : '/login')->with('message', $notice_msg); } } } else { $error_msg = trans('texts.security.wrong_confirmation'); - return Redirect::action('UserController@login')->with('error', $error_msg); + return Redirect::to('/login')->with('error', $error_msg); } } - */ - - /** - * Displays the forgot password form - * - */ - /* - public function forgot_password() - { - return View::make(Config::get('confide.forgot_password_form')); - } - */ - - /** - * Attempt to send change password link to the given email - * - */ - /* - public function do_forgot_password() - { - Confide::forgotPassword(Input::get('email')); - - $notice_msg = trans('texts.security.password_forgot'); - - return Redirect::action('UserController@login') - ->with('message', $notice_msg); - } - */ - - /** - * Shows the change password form with the given token - * - */ - /* - public function reset_password($token = false) - { - return View::make(Config::get('confide::reset_password_form')) - ->with('token', $token); - } - */ - - /** - * Attempt change password of the user - * - */ - /* - public function do_reset_password() - { - if (Auth::check()) { - $rules = [ - 'password' => 'required|between:4,11|confirmed', - 'password_confirmation' => 'between:4,11', - ]; - $validator = Validator::make(Input::all(), $rules); - - if ($validator->fails()) { - return Redirect::to('user/reset')->withInput()->withErrors($validator); - } - - $user = Auth::user(); - $user->password = Input::get('password'); - $user->save(); - - Session::flash('message', trans('texts.security.password_reset')); - - return Redirect::to('/dashboard'); - } else { - $input = array( - 'token' => Input::get('token'), - 'password' => Input::get('password'), - 'password_confirmation' => Input::get('password_confirmation'), - ); - - // By passing an array with the token, password and confirmation - if (Confide::resetPassword($input)) { - $notice_msg = trans('texts.security.password_reset'); - - return Redirect::action('UserController@login') - ->with('notice', $notice_msg); - } else { - $error_msg = trans('texts.security.wrong_password_reset'); - - return Redirect::action('UserController@reset_password', array('token' => $input['token'])) - ->withInput() - ->with('error', $error_msg); - } - } - } - */ /** * Log the user out of the application. diff --git a/app/Http/routes.php b/app/Http/routes.php index 18f5914afd70..4f32dfb53d94 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -71,12 +71,12 @@ get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEma post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail')); get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset')); post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset')); +get('user/confirm/{code}', 'UserController@confirm'); /* // Confide routes Route::get('login', 'UserController@login'); Route::post('login', 'UserController@do_login'); -Route::get('user/confirm/{code}', 'UserController@confirm'); Route::get('forgot_password', 'UserController@forgot_password'); Route::post('forgot_password', 'UserController@do_forgot_password'); Route::get('user/reset/{token?}', 'UserController@reset_password'); diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index d1c5e6ded3dc..56e6d8d933fc 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -1,7 +1,6 @@ password = str_random(RANDOM_KEY_LENGTH); - $user->email = $user->username = str_random(RANDOM_KEY_LENGTH); + //$user->email = $user->username = str_random(RANDOM_KEY_LENGTH); } else { $user->first_name = $firstName; $user->last_name = $lastName; @@ -46,6 +46,10 @@ class AccountRepository $user->confirmed = !Utils::isNinja(); $user->registered = !Utils::isNinja(); + if (!$user->confirmed) { + $user->confirmation_code = str_random(RANDOM_KEY_LENGTH); + } + $account->users()->save($user); return $account; diff --git a/database/migrations/2015_03_30_100000_create_password_resets_table.php b/database/migrations/2015_03_30_100000_create_password_resets_table.php index 679df38f8838..30be80c253d2 100644 --- a/database/migrations/2015_03_30_100000_create_password_resets_table.php +++ b/database/migrations/2015_03_30_100000_create_password_resets_table.php @@ -12,12 +12,7 @@ class CreatePasswordResetsTable extends Migration { */ public function up() { - Schema::create('password_resets', function(Blueprint $table) - { - $table->string('email')->index(); - $table->string('token')->index(); - $table->timestamp('created_at'); - }); + Schema::rename('password_reminders', 'password_resets'); } /** @@ -27,7 +22,7 @@ class CreatePasswordResetsTable extends Migration { */ public function down() { - Schema::drop('password_resets'); + Schema::rename('password_resets', 'password_reminders'); } } diff --git a/resources/views/accounts/nav_advanced.blade.php b/resources/views/accounts/nav_advanced.blade.php index 30b598c7775c..61b331261850 100644 --- a/resources/views/accounts/nav_advanced.blade.php +++ b/resources/views/accounts/nav_advanced.blade.php @@ -9,7 +9,7 @@ @if (!Auth::user()->account->isPro())
-
{{ trans('texts.pro_plan_advanced_settings', ['link'=>''.trans('texts.pro_plan.remove_logo_link').'']) }}
+
{!! trans('texts.pro_plan_advanced_settings', ['link'=>''.trans('texts.pro_plan.remove_logo_link').'']) !!}
 

 

@endif diff --git a/resources/views/emails/confirm_html.blade.php b/resources/views/emails/confirm_html.blade.php index bcd4ca4b1ed5..5e17178ac7e5 100644 --- a/resources/views/emails/confirm_html.blade.php +++ b/resources/views/emails/confirm_html.blade.php @@ -28,8 +28,8 @@

{{ $invitationMessage . trans('texts.confirmation_message') }}
- - {{{ URL::to("user/confirm/{$user->confirmation_code}") }}} + + {{ URL::to("user/confirm/{$user->confirmation_code}") }}

diff --git a/resources/views/emails/confirm_text.blade.php b/resources/views/emails/confirm_text.blade.php index ff5c8107c40e..37ee70f320a7 100644 --- a/resources/views/emails/confirm_text.blade.php +++ b/resources/views/emails/confirm_text.blade.php @@ -1,7 +1,7 @@ {{ trans('texts.confirmation_header') }} {{ $invitationMessage . trans('texts.confirmation_message') }} -{{{ URL::to("user/confirm/{$user->confirmation_code}") }}} +{{ URL::to("user/confirm/{$user->confirmation_code}") }} {{ trans('texts.email_signature') }} {{ trans('texts.email_from') }} \ No newline at end of file diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 142c0deeb2e4..053266330854 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -57,9 +57,9 @@

@@ -54,7 +54,7 @@
{{ trans('public.plans.email_support') }}
{{ trans('public.plans.remove_created_by') }}
{{ trans('public.plans.latest_features') }}
-
{{ trans('public.plans.pricing') }}

{{ trans('public.plans.year_price') }}

+
{!! trans('public.plans.pricing') !!}

{!! trans('public.plans.year_price') !!}