1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Support accepting terms

This commit is contained in:
Hillel Coren 2018-03-12 15:37:05 +02:00
parent c09c586015
commit 57cca8a6a4
8 changed files with 88 additions and 0 deletions

View File

@ -340,6 +340,7 @@ if (! defined('APP_NAME')) {
define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'http://docs.invoiceninja.com/en/latest')); define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'http://docs.invoiceninja.com/en/latest'));
define('NINJA_DATE', '2000-01-01'); define('NINJA_DATE', '2000-01-01');
define('NINJA_VERSION', '4.2.2' . env('NINJA_VERSION_SUFFIX')); define('NINJA_VERSION', '4.2.2' . env('NINJA_VERSION_SUFFIX'));
define('NINJA_TERMS_VERSION', '');
define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja')); define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja'));
define('SOCIAL_LINK_TWITTER', env('SOCIAL_LINK_TWITTER', 'https://twitter.com/invoiceninja')); define('SOCIAL_LINK_TWITTER', env('SOCIAL_LINK_TWITTER', 'https://twitter.com/invoiceninja'));

View File

@ -392,4 +392,18 @@ class UserController extends BaseController
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
public function acceptTerms()
{
$ip = Request::getClientIp();
$referer = Request::server('HTTP_REFERER');
$message = '';
if (request()->accepted_terms) {
auth()->user()->acceptedLatestTerms($ip);
$message = trans('texts.accepted_terms');
}
return redirect($referer)->withMessage($message);
}
} }

View File

@ -452,6 +452,23 @@ class User extends Authenticatable
{ {
return $this->slack_webhook_url; return $this->slack_webhook_url;
} }
public function hasAcceptedLatestTerms()
{
if (! NINJA_TERMS_VERSION) {
return true;
}
return $this->accepted_terms_version == NINJA_TERMS_VERSION;
}
public function acceptedLatestTerms($ip)
{
$this->accepted_terms_version = NINJA_TERMS_VERSION;
$this->accepted_terms_timestamp = date('Y-m-d H:i:s');
$this->accepted_terms_ip = $ip;
$this->save();
}
} }
User::created(function ($user) User::created(function ($user)

View File

@ -15,6 +15,10 @@ class AddSlackNotifications extends Migration
{ {
Schema::table('users', function ($table) { Schema::table('users', function ($table) {
$table->string('slack_webhook_url')->nullable(); $table->string('slack_webhook_url')->nullable();
$table->string('accepted_terms_version')->nullable();
$table->timestamp('accepted_terms_timestamp')->nullable();
$table->string('accepted_terms_ip')->nullable();
}); });
} }
@ -27,6 +31,10 @@ class AddSlackNotifications extends Migration
{ {
Schema::table('users', function ($table) { Schema::table('users', function ($table) {
$table->dropColumn('slack_webhook_url'); $table->dropColumn('slack_webhook_url');
$table->dropColumn('accepted_terms_version');
$table->dropColumn('accepted_terms_timestamp');
$table->dropColumn('accepted_terms_ip');
}); });
} }
} }

View File

@ -2770,6 +2770,8 @@ $LANG = array(
'received_new_payment' => 'You\'ve received a new payment!', 'received_new_payment' => 'You\'ve received a new payment!',
'slack_webhook_help' => 'Receive payment notifications using :link.', 'slack_webhook_help' => 'Receive payment notifications using :link.',
'slack_incoming_webhooks' => 'Slack incoming webhooks', 'slack_incoming_webhooks' => 'Slack incoming webhooks',
'accept' => 'Accept',
'accepted_terms' => 'Successfully accepted the latest terms of service',
); );

View File

@ -501,6 +501,10 @@
@include('partials.sign_up') @include('partials.sign_up')
@include('partials.keyboard_shortcuts') @include('partials.keyboard_shortcuts')
@if (auth()->check() && ! auth()->user()->hasAcceptedLatestTerms())
@include('partials.accept_terms')
@endif
</div> </div>
<p>&nbsp;</p> <p>&nbsp;</p>

View File

@ -0,0 +1,41 @@
{!! Former::open('/accept_terms')->id('acceptTermsForm')->rules([
'accepted_terms' => 'required',
]) !!}
<div class="modal fade" id="acceptTermsModal" tabindex="-1" role="dialog"
data-backdrop="static" aria-labelledby="acceptTermsModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.terms_of_service') }}</h4>
</div>
<div class="container" style="width: 100%; padding-bottom: 0px !important">
<div class="panel panel-default">
<div class="panel-body">
{!! Former::checkbox('accepted_terms')->text('agree_to_terms')->raw()->value(1) !!}
</div>
</div>
</div>
<div class="modal-footer">
{!! Button::success(trans('texts.accept'))->submit() !!}
</div>
</div>
</div>
</div>
{!! Former::close() !!}
<script type="text/javascript">
function acceptLatestTerms()
{
$('#acceptTermsForm').submit();
}
$(function() {
$('#acceptTermsModal').modal('show');
})
</script>

View File

@ -129,6 +129,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
Route::post('save_sidebar_state', 'UserController@saveSidebarState'); Route::post('save_sidebar_state', 'UserController@saveSidebarState');
Route::post('contact_us', 'HomeController@contactUs'); Route::post('contact_us', 'HomeController@contactUs');
Route::post('handle_command', 'BotController@handleCommand'); Route::post('handle_command', 'BotController@handleCommand');
Route::post('accept_terms', 'UserController@acceptTerms');
Route::post('signup/validate', 'AccountController@checkEmail'); Route::post('signup/validate', 'AccountController@checkEmail');
Route::post('signup/submit', 'AccountController@submitSignup'); Route::post('signup/submit', 'AccountController@submitSignup');