Skip to content

Commit

Permalink
Add user nicName field
Browse files Browse the repository at this point in the history
  • Loading branch information
PSkierniewski committed Apr 3, 2016
1 parent e43b4c5 commit c9d41bf
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ VANILLA_FORUM_SECRET=
DISQUS_API_KEY=
DISQUS_API_SECRET=
DISQUS_DOMAIN=
DISQUS_ENABLED=false
2 changes: 1 addition & 1 deletion app/Http/Controllers/AccountApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function update($id)
if (!Input::has('password')) {
$this->validator->setData(Input::except(['password', 'password_confirmation']));
}
$input = $this->validator->validate('update');
$user = $this->userRepo->getById($id);
$input = $this->validator->bind('nickName', ['userId' => $user->id])->validate('update');
$this->userRepo->update($user, $input);
return Response::json(['success' => true]);
} catch (ValidationException $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ($view) {
if ($user) {
$data = [
"id" => $user["id"],
"username" => $user["firstName"] . ' ' . $user["lastName"],
"username" => $user->getPresenter()->displayName(),
"email" => $user["email"],
//"avatar" => $user["avatar"],
];
Expand Down
2 changes: 1 addition & 1 deletion config/disqus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
'api_key' => env('DISQUS_API_KEY', ''),
'api_secret' => env('DISQUS_API_SECRET', ''),
'domain' => env('DISQUS_DOMAIN', ''), //<DISQUS_DOMAIN>.disqus.com/embed.js
'enabled' => false,
'enabled' => env('DISQUS_ENABLED', 'false'),
];
1 change: 1 addition & 0 deletions config/gzero.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'seoTitleAlternativeField' => 'title',
'seoDescriptionAlternativeField' => 'body',
'seoDescLength' => 160,
'useUsersNickNames' => true,
'siteDesc' => 'Content management system.',
'multilang' => [
'enabled' => true,
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
'loginWith' => 'or sign in with',
'logout' => 'Logout',
'newPassword' => 'New password',
'nickName' => 'Nick name',
'noTranslation' => 'No translation',
'notAMember' => 'Not a member yet?',
'notPublished' => 'Not published',
'numberOfViews' => 'Number of views:',
'optional' => 'optional',
'options' => 'Options',
'order' => 'Order',
'pageNotFound' => 'Page not found',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/pl/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
'loginWith' => 'lub zaloguj się z',
'logout' => 'Wyloguj',
'newPassword' => 'Nowe hasło',
'nickName' => 'Nick',
'noTranslation' => 'Brak tłumaczenia',
'notAMember' => 'Nie masz jeszcze konta?',
'notPublished' => 'Niepublikowany',
'numberOfViews' => 'Liczba wyświetleń:',
'optional' => 'opcjonalnie',
'options' => 'Opcje',
'order' => 'Kolejność',
'pageNotFound' => 'Nie znaleziono strony',
Expand Down
9 changes: 9 additions & 0 deletions resources/views/account/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<div class="col-md-5">
<form id="edit-account-form" action="#" method="POST" role="form">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group{{ $errors->first('nickName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.nickName')</label>
<input type="text" id="nickName" name="nickName" class="form-control"
value="{{ $user->nickName }}"
placeholder="@lang('common.nickName')">
@if($errors->first('nickName'))
<p class="help-block">{{ $errors->first('nickName') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('firstName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.firstName')</label>
<input type="text" id="firstName" name="firstName" class="form-control"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/account/menu.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@section('menuTree')
<img src="{{ Gravatar::src(Auth::user()->email, 150) }}" class="center-block img-avatar img-circle">
<h3>{{ Auth::user()->firstName }} {{ Auth::user()->lastName }}</h3>
<h3>{{ Auth::user()->getPresenter()->displayName() }}</h3>
@foreach($menu as $link)
<li class="{{ (URL::full() == $link['url']) ? 'active' : '' }}">
@if($link['children'])
Expand Down
13 changes: 11 additions & 2 deletions resources/views/auth/register.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@
<p class="help-block">{{ $errors->first('email') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('nickName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.nickName')</label>
<input type="text" id="nickName" name="nickName" class="form-control"
value="{{old('nickName')}}"
placeholder="@lang('common.nickName')">
@if($errors->first('nickName'))
<p class="help-block">{{ $errors->first('nickName') }}</p>
@endif
</div>
<div class="form-group{{ $errors->first('firstName') ? ' has-error' : '' }}">
<label class="control-label" for="firstName">@lang('common.firstName')</label>
<input type="text" id="firstName" name="firstName" class="form-control"
value="{{old('firstName')}}"
placeholder="@lang('common.firstName')">
placeholder="@lang('common.firstName') (@lang('common.optional'))">
@if($errors->first('firstName'))
<p class="help-block">{{ $errors->first('firstName') }}</p>
@endif
Expand All @@ -32,7 +41,7 @@
<label class="control-label" for="lastName">@lang('common.lastName')</label>
<input type="text" id="lastName" name="lastName" class="form-control"
value="{{old('lastName')}}"
placeholder="@lang('common.lastName')">
placeholder="@lang('common.lastName') (@lang('common.optional'))">
@if($errors->first('lastName'))
<p class="help-block">{{ $errors->first('lastName') }}</p>
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/includes/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<img src="{{ Gravatar::src(Auth::user()->email, 35) }}"
class="navbar-avatar img-circle">
{{ Auth::user()->firstName }} {{ Auth::user()->lastName }}
{{ Auth::user()->getPresenter()->displayName() }}
<i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
Expand Down
2 changes: 1 addition & 1 deletion scripts/link_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function contains() {
}

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PACKAGES=("admin" "api" "cms" "social")
PACKAGES=("admin" "api" "cms" "social" "vanilla-integration")
OPERATIONS=("mount" "umount")
PACKAGE=$1
OPERATION=$2
Expand Down
15 changes: 8 additions & 7 deletions tests/_data/dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CREATE TABLE `BlockTypes` (

LOCK TABLES `BlockTypes` WRITE;
/*!40000 ALTER TABLE `BlockTypes` DISABLE KEYS */;
INSERT INTO `BlockTypes` VALUES ('basic',1,'2016-03-24 09:47:45','2016-03-24 09:47:45'),('content',1,'2016-03-24 09:47:45','2016-03-24 09:47:45'),('menu',1,'2016-03-24 09:47:45','2016-03-24 09:47:45'),('slider',1,'2016-03-24 09:47:45','2016-03-24 09:47:45'),('widget',1,'2016-03-24 09:47:45','2016-03-24 09:47:45');
INSERT INTO `BlockTypes` VALUES ('basic',1,'2016-04-03 16:43:47','2016-04-03 16:43:47'),('content',1,'2016-04-03 16:43:47','2016-04-03 16:43:47'),('menu',1,'2016-04-03 16:43:47','2016-04-03 16:43:47'),('slider',1,'2016-04-03 16:43:47','2016-04-03 16:43:47'),('widget',1,'2016-04-03 16:43:47','2016-04-03 16:43:47');
/*!40000 ALTER TABLE `BlockTypes` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -174,7 +174,7 @@ CREATE TABLE `ContentTypes` (

LOCK TABLES `ContentTypes` WRITE;
/*!40000 ALTER TABLE `ContentTypes` DISABLE KEYS */;
INSERT INTO `ContentTypes` VALUES ('category',1,'2016-03-24 09:47:44','2016-03-24 09:47:44'),('content',1,'2016-03-24 09:47:44','2016-03-24 09:47:44');
INSERT INTO `ContentTypes` VALUES ('category',1,'2016-04-03 16:43:47','2016-04-03 16:43:47'),('content',1,'2016-04-03 16:43:47','2016-04-03 16:43:47');
/*!40000 ALTER TABLE `ContentTypes` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -248,7 +248,7 @@ CREATE TABLE `Langs` (

LOCK TABLES `Langs` WRITE;
/*!40000 ALTER TABLE `Langs` DISABLE KEYS */;
INSERT INTO `Langs` VALUES ('en','en_US',1,1,'2016-03-24 09:47:43','2016-03-24 09:47:43'),('pl','pl_PL',1,0,'2016-03-24 09:47:43','2016-03-24 09:47:43'),('de','de_DE',0,0,'2016-03-24 09:47:43','2016-03-24 09:47:43'),('fr','fr_FR',0,0,'2016-03-24 09:47:43','2016-03-24 09:47:43');
INSERT INTO `Langs` VALUES ('en','en_US',1,1,'2016-04-03 16:43:46','2016-04-03 16:43:46'),('pl','pl_PL',1,0,'2016-04-03 16:43:46','2016-04-03 16:43:46'),('de','de_DE',0,0,'2016-04-03 16:43:46','2016-04-03 16:43:46'),('fr','fr_FR',0,0,'2016-04-03 16:43:46','2016-04-03 16:43:46');
/*!40000 ALTER TABLE `Langs` ENABLE KEYS */;
UNLOCK TABLES;

Expand All @@ -274,7 +274,7 @@ CREATE TABLE `OptionCategories` (

LOCK TABLES `OptionCategories` WRITE;
/*!40000 ALTER TABLE `OptionCategories` DISABLE KEYS */;
INSERT INTO `OptionCategories` VALUES ('general','2016-03-24 09:47:44','2016-03-24 09:47:44'),('seo','2016-03-24 09:47:44','2016-03-24 09:47:44');
INSERT INTO `OptionCategories` VALUES ('general','2016-04-03 16:43:47','2016-04-03 16:43:47'),('seo','2016-04-03 16:43:47','2016-04-03 16:43:47');
/*!40000 ALTER TABLE `OptionCategories` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -304,7 +304,7 @@ CREATE TABLE `Options` (

LOCK TABLES `Options` WRITE;
/*!40000 ALTER TABLE `Options` DISABLE KEYS */;
INSERT INTO `Options` VALUES (1,'siteName','general','{\"en\":\"G-ZERO CMS\",\"pl\":\"G-ZERO CMS\",\"de\":\"G-ZERO CMS\",\"fr\":\"G-ZERO CMS\"}','2016-03-24 09:47:44','2016-03-24 09:47:44'),(2,'siteDesc','general','{\"en\":\"Content management system.\",\"pl\":\"Content management system.\",\"de\":\"Content management system.\",\"fr\":\"Content management system.\"}','2016-03-24 09:47:44','2016-03-24 09:47:44'),(3,'defaultPageSize','general','{\"en\":5,\"pl\":5,\"de\":5,\"fr\":5}','2016-03-24 09:47:44','2016-03-24 09:47:44'),(4,'cookiesPolicyUrl','general','{\"en\":null,\"pl\":null,\"de\":null,\"fr\":null}','2016-03-24 09:47:44','2016-03-24 09:47:44'),(5,'seoDescLength','seo','{\"en\":160,\"pl\":160,\"de\":160,\"fr\":160}','2016-03-24 09:47:44','2016-03-24 09:47:44'),(6,'googleAnalyticsId','seo','{\"en\":null,\"pl\":null,\"de\":null,\"fr\":null}','2016-03-24 09:47:44','2016-03-24 09:47:44');
INSERT INTO `Options` VALUES (1,'siteName','general','{\"en\":\"G-ZERO CMS\",\"pl\":\"G-ZERO CMS\",\"de\":\"G-ZERO CMS\",\"fr\":\"G-ZERO CMS\"}','2016-04-03 16:43:47','2016-04-03 16:43:47'),(2,'siteDesc','general','{\"en\":\"Content management system.\",\"pl\":\"Content management system.\",\"de\":\"Content management system.\",\"fr\":\"Content management system.\"}','2016-04-03 16:43:47','2016-04-03 16:43:47'),(3,'defaultPageSize','general','{\"en\":5,\"pl\":5,\"de\":5,\"fr\":5}','2016-04-03 16:43:47','2016-04-03 16:43:47'),(4,'cookiesPolicyUrl','general','{\"en\":null,\"pl\":null,\"de\":null,\"fr\":null}','2016-04-03 16:43:47','2016-04-03 16:43:47'),(5,'seoDescLength','seo','{\"en\":160,\"pl\":160,\"de\":160,\"fr\":160}','2016-04-03 16:43:47','2016-04-03 16:43:47'),(6,'googleAnalyticsId','seo','{\"en\":null,\"pl\":null,\"de\":null,\"fr\":null}','2016-04-03 16:43:47','2016-04-03 16:43:47');
/*!40000 ALTER TABLE `Options` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -433,6 +433,7 @@ CREATE TABLE `Users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`nickName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`firstName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lastName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`rememberToken` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
Expand All @@ -451,7 +452,7 @@ CREATE TABLE `Users` (

LOCK TABLES `Users` WRITE;
/*!40000 ALTER TABLE `Users` DISABLE KEYS */;
INSERT INTO `Users` VALUES (1,'admin@gzero.pl','$2y$10$1VzgwEjGBfam3lN2wWeU8.q83SWpt6OlGV8qc71nEveCrDc1Nwlty','John','Doe','cUMbAqMU7uXdeWaGWSRwcmXQFRTe3VZ8PMvEVQvEVEnXBuWcNvCAX3bEXixL',1,0,'2016-03-24 09:47:44','2016-03-24 11:04:42');
INSERT INTO `Users` VALUES (1,'admin@gzero.pl','$2y$10$iDOTV75LH2aQFq9iL8Qvw.TTt8pekafeMSpKi5GkCPAFMod3RLlsW','Admin','John','Doe','',1,0,'2016-04-03 16:43:46','2016-04-03 16:43:46');
/*!40000 ALTER TABLE `Users` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -524,4 +525,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-03-24 13:48:55
-- Dump completed on 2016-04-03 16:44:07
7 changes: 6 additions & 1 deletion tests/functional/LoginCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function register(FunctionalTester $I)
$I->wantTo('register a user');

$I->amOnPage('/en/register');
$I->fillField('nickName', 'NickName');
$I->fillField('firstName', 'John');
$I->fillField('lastName', 'Doe');
$I->fillField('email', 'example@example.com');
Expand All @@ -36,6 +37,7 @@ public function registerAlreadyExistingUser(FunctionalTester $I)
$I->haveRecord(
'Users',
[
'nickName' => 'NickName',
'firstName' => 'John',
'lastName' => 'Doe',
'email' => 'john@doe.com',
Expand All @@ -46,12 +48,14 @@ public function registerAlreadyExistingUser(FunctionalTester $I)
);

$I->amOnPage('/en/register');
$I->fillField('nickName', 'NickName');
$I->fillField('firstName', 'John');
$I->fillField('lastName', 'Doe');
$I->fillField('email', 'john@doe.com');
$I->fillField('password', 'password');
$I->click('button[type=submit]');
$I->see('This email is already registered.');
$I->see('The email has already been taken.');
$I->see('The nick name has already been taken.');
$I->dontSeeAuthentication();
}

Expand All @@ -60,6 +64,7 @@ public function preventSpamUserRegistrations(FunctionalTester $I)
$I->wantTo('prevent a spammer users registrations');

$I->amOnPage('/en/register');
$I->fillField('nickName', 'NickName');
$I->fillField('firstName', 'John');
$I->fillField('lastName', 'Doe');
$I->fillField('email', 'example@example.com');
Expand Down

0 comments on commit c9d41bf

Please sign in to comment.