Skip to content

Commit

Permalink
Merge 603bd68 into bf7fd91
Browse files Browse the repository at this point in the history
  • Loading branch information
PSkierniewski authored May 9, 2017
2 parents bf7fd91 + 603bd68 commit 53fef1e
Show file tree
Hide file tree
Showing 45 changed files with 777 additions and 85 deletions.
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ deploy to production:
-e POSTGRES_USER=$PRODUCTION_DB_USER
-e POSTGRES_PASSWORD=$PRODUCTION_DB_PASSWORD
-e POSTGRES_DATABASE=$PRODUCTION_DB_DATABASE
-e MAIL_HOST=$PRODUCTION_MAIL_HOST
-e MAIL_PORT=$PRODUCTION_MAIL_PORT
-e MAIL_USERNAME=$PRODUCTION_MAIL_USERNAME
-e MAIL_PASSWORD=$PRODUCTION_MAIL_PASSWORD
-e MAIL_FROM_NAME=$PRODUCTION_MAIL_FROM_NAME
-e MAIL_FROM_ADDRESS=$PRODUCTION_MAIL_FROM_ADDRESS
-e UPLOAD_DISK=$PRODUCTION_UPLOAD_DISK
-e S3_KEY=$PRODUCTION_S3_KEY
-e S3_SECRET=$PRODUCTION_S3_SECRET
Expand Down
4 changes: 4 additions & 0 deletions ansible/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
- "DOCKER_APP_IMAGE != ''"
- "DOMAIN != ''"
- "LETSENCRYPT_EMAIL != ''"
- "MAIL_HOST != ''"
- "MAIL_PORT != ''"
- "MAIL_PASSWORD != ''"
- "MAIL_USERNAME != ''"
- "MAIL_FROM_NAME != ''"
- "MAIL_FROM_ADDRESS != ''"
- "POSTGRES_DATABASE != ''"
- "POSTGRES_PASSWORD != ''"
- "POSTGRES_PASSWORD != ''"
Expand Down
2 changes: 2 additions & 0 deletions ansible/templates/env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ MAIL_PORT={{ MAIL_PORT | default('587') }}
MAIL_USERNAME={{ MAIL_USERNAME }}
MAIL_PASSWORD={{ MAIL_PASSWORD }}
MAIL_ENCRYPTION={{ MAIL_ENCRYPTION | default('tls') }}
MAIL_FROM_ADDRESS={{ MAIL_FROM_ADDRESS | default('hello@example.com') }}
MAIL_FROM_NAME={{ MAIL_FROM_NAME | default('Example') }}

{% if OAUTH_GOOGLE_CLIENT_ID is defined %}
OAUTH_GOOGLE_CLIENT_ID={{ OAUTH_GOOGLE_CLIENT_ID }}
Expand Down
13 changes: 9 additions & 4 deletions app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public function account()
return view('account.index');
}

public function edit()
public function edit(Request $request)
{
return view('account.edit');
return view('account.edit', ['isUserEmailSet' => strpos($request->user()->email, '@')]);
}

public function welcome(Request $request)
Expand All @@ -28,8 +28,13 @@ public function welcome(Request $request)
return redirect()->route('home');
}

public function oauth()
public function oauth(Request $request)
{

if (!$request->user()->isSuperAdmin()) {
return abort(404);
}

return view('account.oauth');
}
}
}
2 changes: 2 additions & 0 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class ResetPasswordController extends BaseController

use ResetsPasswords;

protected $redirectTo = '/';

/**
* Create a new controller instance.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use App\Notifications\ResetPasswordNotification;
use Illuminate\Notifications\Notifiable;
use Gzero\Entity\User as BaseUser;

Expand All @@ -15,4 +16,15 @@ public function isGuest()
{
return false;
}

/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
}
58 changes: 58 additions & 0 deletions app/Notifications/ResetPasswordNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class ResetPasswordNotification extends Notification {
use Queueable;

/**
* The password reset token.
*
* @var string
*/
public $token;

/**
* Create a notification instance.
*
* @param string $token
*
*/
public function __construct($token)
{
$this->token = $token;
}

/**
* Get the notification's channels.
*
* @param mixed $notifiable
*
* @return array|string
*/
public function via($notifiable)
{
return ['mail'];
}

/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->subject(trans('emails.reset_password.subject'))
->greeting(trans('emails.reset_password.greeting'))
->line(trans('emails.reset_password.line_1'))
->action(trans('emails.reset_password.action'), route('password.reset', $this->token))
->line(trans('emails.reset_password.line_2'));
}
}
7 changes: 5 additions & 2 deletions app/Providers/ComposerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public function boot()
'account.menu',
function ($view) {
$menu = app('gzero.menu.account');
$user = auth()->user();
/** @var $menu Register */
$menu->add(new Link(route('account'), trans('user.my_account'), 100));
$menu->add(new Link(route('account.oauth'), trans('user.oauth'), 200));
if ($user && $user->isSuperAdmin()) {
$menu->add(new Link(route('account.oauth'), trans('user.oauth'), 200));
}
$view->with('menu', $menu->getMenu());
}
);
Expand All @@ -30,7 +33,7 @@ function ($view) {
function ($view) {
$data = [];
$user = auth()->user();
if (!$user->isGuest()) {
if ($user && !$user->isGuest()) {
$data = [
"id" => $user["id"],
"username" => $user->getPresenter()->displayName(),
Expand Down
3 changes: 2 additions & 1 deletion resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return [
'404_message' => 'The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.',
'account' => 'Account',
'account_connected' => 'Account connected to external service.',
'account_connected' => 'Account connected to external service.',
'all_rights_reserved' => 'All rights reserved.',
'anonymous' => 'Anonymous',
'author' => 'Author',
Expand Down Expand Up @@ -63,6 +63,7 @@
'send' => 'Send',
'send_password_reset_link' => 'Send password reset link',
'send_reminder' => 'Send reminder',
'set_email_to_edit_account' => 'Set an email address to be able to edit your profile.',
'set_password_to_login' => 'Set password to be able to sign in using your email address.',
'sorry' => 'Sorry!',
'status' => 'Status',
Expand Down
24 changes: 17 additions & 7 deletions resources/lang/en/emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

# modified at 01-04-2015 15:59

return array(
'welcome' => array(
'body' => 'Now that you&rsquo;re an member of the :siteName community, you can login to your account at :domain with the email and password you chose during signup.',
'subject' => 'Welcome to :siteName',
'title' => 'We\'re glad you\'re here.',
),
);
return [
'welcome' => [
'body' => 'Now that you&rsquo;re an member of the :siteName community, you can login to your account at :domain with the email and password you chose during signup.',
'subject' => 'Welcome to :siteName',
'title' => 'We\'re glad you\'re here.',
],
'reset_password' => [
'subject' => 'Password Reset',
'greeting' => 'Hello!',
'line_1' => 'You are receiving this email because we received a password reset request for your account.',
'action' => 'Reset Password',
'line_2' => 'If you did not request a password reset, no further action is required.',
],
'salutation' => 'Regards',
'sub_copy' => 'If you’re having trouble clicking the ":actionText" button, copy and paste the URL below into your web browser:'

];
13 changes: 7 additions & 6 deletions resources/lang/pl/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return [
'404_message' => 'Strona, której szukasz, mogła zostać usunięta, zmieniono jej nazwę lub jest tymczasowo niedostępna.',
'account' => 'Konto',
'account_connected' => 'Konto połaczone z usługą zewnętrzną.',
'account_connected' => 'Konto połaczone z usługą zewnętrzną.',
'all_rights_reserved' => 'Wszelkie prawa zastrzeżone.',
'anonymous' => 'Anonimowy',
'author' => 'Autor',
Expand Down Expand Up @@ -63,16 +63,17 @@
'return_to_sign_in' => 'Wróć do logowania',
'save' => 'Zapisz',
'send' => 'Wyślij',
'send_password_reset_link' => 'Wyślij link resetowania hasła',
'send_reminder' => 'Wyślij przypomnienie',
'set_password_to_login' => 'Ustaw hasło, aby móc zalogować się przy pomocy adresu e-mail.',
'send_password_reset_link' => 'Wyślij link resetowania hasła',
'send_reminder' => 'Wyślij przypomnienie',
'set_email_to_edit_account' => 'Ustaw adres e-mail, aby móc edytować profil.',
'set_password_to_login' => 'Ustaw hasło, aby móc zalogować się przy pomocy adresu e-mail.',
'sorry' => 'Wybacz!',
'status' => 'Status',
'submit' => 'Wyślij',
'title' => 'Tytuł',
'toggle_navigation' => 'Włącz nawigację',
'toggle_navigation' => 'Włącz nawigację',
'type' => 'Typ',
'unknown' => 'Nieznany',
'welcome' => 'Witaj',
'welcome_message' => 'Twoje konto zostało utworzone. Dziękujemy za rejestrację!',
'welcome_message' => 'Twoje konto zostało utworzone. Dziękujemy za rejestrację!',
];
23 changes: 16 additions & 7 deletions resources/lang/pl/emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

# modified at 01-04-2015 16:00

return array(
'welcome' => array(
'body' => 'Teraz, kiedy jesteś członkiem społeczności :siteName możesz się zalogować do swojego konta na :domain używając adresu email i hasła podanego podczas rejestracji.',
'subject' => 'Witamy w :siteName',
'title' => 'Cieszymy się, że jesteś z nami.',
),
);
return [
'welcome' => [
'body' => 'Teraz, kiedy jesteś członkiem społeczności :siteName możesz się zalogować do swojego konta na :domain używając adresu email i hasła podanego podczas rejestracji.',
'subject' => 'Witamy w :siteName',
'title' => 'Cieszymy się, że jesteś z nami.',
],
'reset_password' => [
'subject' => 'Resetowanie hasła',
'greeting' => 'Witaj!',
'line_1' => 'Otrzymujesz ten e-mail, ponieważ otrzymaliśmy prośbę o resetowanie hasła dla Twojego konta.',
'action' => 'Zresetuj hasło',
'line_2' => 'Jeśli nie zażądałeś zresetowania hasła, nie musisz podejmować żadnych działań.'
],
'salutation' => 'Pozdrowienia',
'sub_copy' => 'Jeśli masz kłopoty z kliknięciem przycisku ":actionText", skopiuj i wklej poniższy URL w przeglądarce internetowej:'
];
89 changes: 58 additions & 31 deletions resources/views/account/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,31 @@

@section('content')
<h1 class="page-header">@lang('common.edit')</h1>

@if(!$isUserEmailSet)
<div class="alert alert-info">
<i class="fa fa-info-circle"><!-- icon --></i> @lang('common.set_email_to_edit_account')
</div>
@endif
<div class="row">
<div class="col-md-5">
<div class="col-md-6">
<form id="edit-account-form" action="#" method="POST" role="form">
<div class="form-group{{ $errors->first('nick') ? ' has-error' : '' }}">
<label class="control-label" for="nick">@lang('common.nick')</label>
<input type="text" id="nick" name="nick" class="form-control"
value="{{ $user->nick }}"
placeholder="@lang('common.nick')">
@if($errors->first('nick'))
<p class="help-block">{{ $errors->first('nick') }}</p>
@endif
</div>
@if($isUserEmailSet)
<div class="form-group{{ $errors->first('nick') ? ' has-error' : '' }}">
<label class="control-label" for="nick">@lang('common.nick')</label>
<input type="text" id="nick" name="nick" class="form-control"
value="{{ $user->nick }}"
placeholder="@lang('common.nick')">
@if($errors->first('nick'))
<p class="help-block">{{ $errors->first('nick') }}</p>
@endif
</div>
@else
<div class="form-group">
<label class="control-label">@lang('common.nick')</label>
<p class="form-control-static">{{ $user->nick }}</p>
<input type="hidden" name="nick" value="{{ $user->nick }}">
</div>
@endif
<div class="form-group{{ $errors->first('email') ? ' has-error' : '' }}">
<label class="control-label" for="email">@choice('common.email', 1)</label>
<input type="email" id="email" name="email" class="form-control"
Expand All @@ -32,25 +44,36 @@
<p class="help-block">{{ $errors->first('email') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('firstName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.first_name')</label>
<input type="text" id="firstName" name="firstName" class="form-control"
value="{{ $user->firstName }}"
placeholder="@lang('common.first_name')">
@if($errors->first('firstName'))
<p class="help-block">{{ $errors->first('firstName') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('lastName') ? ' has-error' : '' }}">
<label class="control-label" for="lastName">@lang('common.last_name')</label>
<input type="text" id="lastName" name="lastName" class="form-control"
value="{{ $user->lastName }}"
placeholder="@lang('common.last_name')">
@if($errors->first('lastName'))
<p class="help-block">{{ $errors->first('lastName') }}</p>
@endif
</div>
@if(strpos($user->email,'@'))
@if($isUserEmailSet)
<div class="form-group{{ $errors->first('firstName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.first_name')</label>
<input type="text" id="firstName" name="firstName" class="form-control"
value="{{ $user->firstName }}"
placeholder="@lang('common.first_name')">
@if($errors->first('firstName'))
<p class="help-block">{{ $errors->first('firstName') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('lastName') ? ' has-error' : '' }}">
<label class="control-label" for="lastName">@lang('common.last_name')</label>
<input type="text" id="lastName" name="lastName" class="form-control"
value="{{ $user->lastName }}"
placeholder="@lang('common.last_name')">
@if($errors->first('lastName'))
<p class="help-block">{{ $errors->first('lastName') }}</p>
@endif
</div>
@else
<div class="form-group">
<label class="control-label">@lang('common.first_name')</label>
<p class="form-control-static">{{ $user->firstName }}</p>
</div>
<div class="form-group">
<label class="control-label">@lang('common.last_name')</label>
<p class="form-control-static">{{ $user->lastName }}</p>
</div>
@endif
@if($isUserEmailSet)
@if($user->password)
<div class="separator">
<span>@lang('common.password_change')</span>
Expand Down Expand Up @@ -104,11 +127,15 @@ class="form-control"
data: $('#edit-account-form').serializeObject(),
type: 'PUT',
success: function(xhr) {
Loading.stop();
@if($isUserEmailSet)
Loading.stop();
// set success message
setGlobalMessage('success', "@lang('common.changes_saved_message')");
hideMessages();
clearFormValidationErrors();
@else
location.reload();
@endif
},
error: function(xhr) {
Loading.stop();
Expand Down
Loading

0 comments on commit 53fef1e

Please sign in to comment.