Working on L5

This commit is contained in:
Hillel Coren 2015-04-05 22:15:37 +03:00
parent d47d715181
commit b8f2f59b5b
12 changed files with 30 additions and 181 deletions

View File

@ -10,6 +10,8 @@ use Event;
use Validator; use Validator;
use stdClass; use stdClass;
use App\Models\User;
use App\Models\Activity;
use App\Models\Account; use App\Models\Account;
use App\Models\Country; use App\Models\Country;
use App\Models\Currency; use App\Models\Currency;
@ -688,9 +690,8 @@ class AccountController extends BaseController
$user->email = trim(strtolower(Input::get('new_email'))); $user->email = trim(strtolower(Input::get('new_email')));
$user->username = $user->email; $user->username = $user->email;
$user->password = trim(Input::get('new_password')); $user->password = trim(Input::get('new_password'));
$user->password_confirmation = trim(Input::get('new_password'));
$user->registered = true; $user->registered = true;
$user->amend(); $user->save();
if (Utils::isNinja()) { if (Utils::isNinja()) {
$this->userMailer->sendConfirmation($user); $this->userMailer->sendConfirmation($user);

View File

@ -9,6 +9,7 @@ use Cache;
use Redirect; use Redirect;
use DB; use DB;
use Event; use Event;
use URL;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Invitation; use App\Models\Invitation;

View File

@ -227,7 +227,7 @@ class UserController extends BaseController
$user->email = trim(Input::get('email')); $user->email = trim(Input::get('email'));
$user->registered = true; $user->registered = true;
$user->password = str_random(RANDOM_KEY_LENGTH); $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; $user->public_id = $lastUser->public_id + 1;
} }
@ -257,83 +257,20 @@ class UserController extends BaseController
return Redirect::to('company/advanced_settings/user_management'); 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 * Attempt to confirm account with code
* *
* @param string $code * @param string $code
*/ */
/*
public function confirm($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'); $notice_msg = trans('texts.security.confirmation');
$user = User::where('confirmation_code', '=', $code)->get()->first(); $user->confirmed = true;
$user->confirmation_code = ''; $user->confirmation_code = '';
$user->save(); $user->save();
@ -348,104 +285,15 @@ class UserController extends BaseController
return Redirect::to($invitation->getLink()); return Redirect::to($invitation->getLink());
} else { } else {
return Redirect::action('UserController@login')->with('message', $notice_msg); return Redirect::to(Auth::check() ? '/dashboard' : '/login')->with('message', $notice_msg);
} }
} }
} else { } else {
$error_msg = trans('texts.security.wrong_confirmation'); $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. * Log the user out of the application.

View File

@ -71,12 +71,12 @@ get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEma
post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail')); post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail'));
get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset')); get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset'));
post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset')); post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset'));
get('user/confirm/{code}', 'UserController@confirm');
/* /*
// Confide routes // Confide routes
Route::get('login', 'UserController@login'); Route::get('login', 'UserController@login');
Route::post('login', 'UserController@do_login'); Route::post('login', 'UserController@do_login');
Route::get('user/confirm/{code}', 'UserController@confirm');
Route::get('forgot_password', 'UserController@forgot_password'); Route::get('forgot_password', 'UserController@forgot_password');
Route::post('forgot_password', 'UserController@do_forgot_password'); Route::post('forgot_password', 'UserController@do_forgot_password');
Route::get('user/reset/{token?}', 'UserController@reset_password'); Route::get('user/reset/{token?}', 'UserController@reset_password');

View File

@ -1,7 +1,6 @@
<?php namespace App\Ninja\Repositories; <?php namespace App\Ninja\Repositories;
use Auth; use Auth;
use Language;
use Request; use Request;
use Session; use Session;
use Utils; use Utils;
@ -11,6 +10,7 @@ use App\Models\Invitation;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\InvoiceItem; use App\Models\InvoiceItem;
use App\Models\Client; use App\Models\Client;
use App\Models\Language;
use App\Models\Contact; use App\Models\Contact;
use App\Models\Account; use App\Models\Account;
use App\Models\User; use App\Models\User;
@ -35,7 +35,7 @@ class AccountRepository
$user = new User(); $user = new User();
if (!$firstName && !$lastName && !$email && !$password) { if (!$firstName && !$lastName && !$email && !$password) {
$user->password = str_random(RANDOM_KEY_LENGTH); $user->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 { } else {
$user->first_name = $firstName; $user->first_name = $firstName;
$user->last_name = $lastName; $user->last_name = $lastName;
@ -46,6 +46,10 @@ class AccountRepository
$user->confirmed = !Utils::isNinja(); $user->confirmed = !Utils::isNinja();
$user->registered = !Utils::isNinja(); $user->registered = !Utils::isNinja();
if (!$user->confirmed) {
$user->confirmation_code = str_random(RANDOM_KEY_LENGTH);
}
$account->users()->save($user); $account->users()->save($user);
return $account; return $account;

View File

@ -12,12 +12,7 @@ class CreatePasswordResetsTable extends Migration {
*/ */
public function up() public function up()
{ {
Schema::create('password_resets', function(Blueprint $table) Schema::rename('password_reminders', 'password_resets');
{
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at');
});
} }
/** /**
@ -27,7 +22,7 @@ class CreatePasswordResetsTable extends Migration {
*/ */
public function down() public function down()
{ {
Schema::drop('password_resets'); Schema::rename('password_resets', 'password_reminders');
} }
} }

View File

@ -9,7 +9,7 @@
@if (!Auth::user()->account->isPro()) @if (!Auth::user()->account->isPro())
<center> <center>
<div style="font-size:larger;" class="col-md-8 col-md-offset-2">{{ trans('texts.pro_plan_advanced_settings', ['link'=>'<a href="#" onclick="showProPlan(\''.$feature.'\')">'.trans('texts.pro_plan.remove_logo_link').'</a>']) }}</div> <div style="font-size:larger;" class="col-md-8 col-md-offset-2">{!! trans('texts.pro_plan_advanced_settings', ['link'=>'<a href="#" onclick="showProPlan(\''.$feature.'\')">'.trans('texts.pro_plan.remove_logo_link').'</a>']) !!}</div>
&nbsp;<p/>&nbsp; &nbsp;<p/>&nbsp;
</center> </center>
@endif @endif

View File

@ -28,8 +28,8 @@
<p> <p>
{{ $invitationMessage . trans('texts.confirmation_message') }}<br/> {{ $invitationMessage . trans('texts.confirmation_message') }}<br/>
<a href='{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}'> <a href='{{ URL::to("user/confirm/{$user->confirmation_code}") }}'>
{{{ URL::to("user/confirm/{$user->confirmation_code}") }}} {{ URL::to("user/confirm/{$user->confirmation_code}") }}
</a> </a>
<p/> <p/>

View File

@ -1,7 +1,7 @@
{{ trans('texts.confirmation_header') }} {{ trans('texts.confirmation_header') }}
{{ $invitationMessage . trans('texts.confirmation_message') }} {{ $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_signature') }}
{{ trans('texts.email_from') }} {{ trans('texts.email_from') }}

View File

@ -57,9 +57,9 @@
<div class="navbar-form navbar-right"> <div class="navbar-form navbar-right">
@if (Auth::check()) @if (Auth::check())
@if (!Auth::user()->registered) @if (!Auth::user()->registered)
{!! Button::success(trans('texts.sign_up'), array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal'))->small() !!} &nbsp; {!! Button::success(trans('texts.sign_up'))->withAttributes(array('id' => 'signUpButton', 'data-toggle'=>'modal', 'data-target'=>'#signUpModal'))->small() !!} &nbsp;
@elseif (!Auth::user()->isPro()) @elseif (!Auth::user()->isPro())
{!! Button::success(trans('texts.go_pro'), array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal'))->small() !!} &nbsp; {!! Button::success(trans('texts.go_pro'))->withAttributes(array('id' => 'proPlanButton', 'data-toggle'=>'modal', 'data-target'=>'#proPlanModal'))->small() !!} &nbsp;
@endif @endif
@endif @endif
@ -94,7 +94,7 @@
<li>{!! link_to('company/products', uctrans('texts.product_library')) !!}</li> <li>{!! link_to('company/products', uctrans('texts.product_library')) !!}</li>
<li>{!! link_to('company/notifications', uctrans('texts.notifications')) !!}</li> <li>{!! link_to('company/notifications', uctrans('texts.notifications')) !!}</li>
<li>{!! link_to('company/import_export', uctrans('texts.import_export')) !!}</li> <li>{!! link_to('company/import_export', uctrans('texts.import_export')) !!}</li>
<li><a href="{{ url('company/advanced_settings/invoice_settings') }}">{{ uctrans('texts.advanced_settings') . Utils::getProLabel(ACCOUNT_ADVANCED_SETTINGS) }}</a></li> <li><a href="{{ url('company/advanced_settings/invoice_settings') }}">{!! uctrans('texts.advanced_settings') . Utils::getProLabel(ACCOUNT_ADVANCED_SETTINGS) !!}</a></li>
<li class="divider"></li> <li class="divider"></li>
<li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li> <li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li>

View File

@ -355,7 +355,7 @@
@if (!Auth::user()->account->isPro()) @if (!Auth::user()->account->isPro())
<div style="font-size:larger"> <div style="font-size:larger">
{{ trans('texts.pro_plan.remove_logo', ['link'=>'<a href="#" onclick="showProPlan(\'remove_logo\')">'.trans('texts.pro_plan.remove_logo_link').'</a>']) }} {!! trans('texts.pro_plan.remove_logo', ['link'=>'<a href="#" onclick="showProPlan(\'remove_logo\')">'.trans('texts.pro_plan.remove_logo_link').'</a>']) !!}
</div> </div>
@endif @endif

View File

@ -35,7 +35,7 @@
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.email_support') }}</div><span class="glyphicon glyphicon-remove"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.email_support') }}</div><span class="glyphicon glyphicon-remove"></div>
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.remove_created_by') }}</div><span class="glyphicon glyphicon-remove"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.remove_created_by') }}</div><span class="glyphicon glyphicon-remove"></div>
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.latest_features') }}</div><span class="glyphicon glyphicon-remove"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.latest_features') }}</div><span class="glyphicon glyphicon-remove"></div>
<div class="cell price"><div class="hide-desktop">{{ trans('public.plans.pricing') }}</div><p>{{ trans('public.plans.free_always') }}</p></div> <div class="cell price"><div class="hide-desktop">{!! trans('public.plans.pricing') !!}</div><p>{!! trans('public.plans.free_always') !!}</p></div>
</div> </div>
<div class="pro col-md-4"> <div class="pro col-md-4">
@ -54,7 +54,7 @@
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.email_support') }}</div><span class="glyphicon glyphicon-ok"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.email_support') }}</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.remove_created_by') }}</div><span class="glyphicon glyphicon-ok"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.remove_created_by') }}</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell"><div class="hide-desktop">{{ trans('public.plans.latest_features') }}</div><span class="glyphicon glyphicon-ok"></div> <div class="cell"><div class="hide-desktop">{{ trans('public.plans.latest_features') }}</div><span class="glyphicon glyphicon-ok"></div>
<div class="cell price"><div class="hide-desktop">{{ trans('public.plans.pricing') }}</div><p>{{ trans('public.plans.year_price') }}</p></div> <div class="cell price"><div class="hide-desktop">{!! trans('public.plans.pricing') !!}</div><p>{!! trans('public.plans.year_price') !!}</p></div>
<!-- <div class="cell"><a href="#"><div class="cta"><h2 onclick="return getStarted()">GO PRO <span>+</span></h2></div> </a>--> <!-- <div class="cell"><a href="#"><div class="cta"><h2 onclick="return getStarted()">GO PRO <span>+</span></h2></div> </a>-->
</div> </div>