Added new user profile fields

* company
* phone_number

Change-Id: I19c195bd238cef441d7de09eccfc886f4078aa0c
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2020-07-15 12:50:52 -03:00
parent 0f1397f4ab
commit b81654bb0e
10 changed files with 142 additions and 6 deletions

View File

@ -79,7 +79,6 @@ final class UserApiController extends APICRUDController {
]; ];
} }
/** /**
* @param $id * @param $id
* @return mixed * @return mixed
@ -205,7 +204,9 @@ final class UserApiController extends APICRUDController {
'birthday' => 'nullable|date_format:U', 'birthday' => 'nullable|date_format:U',
'password' => 'sometimes|string|min:8|confirmed', 'password' => 'sometimes|string|min:8|confirmed',
'email_verified' => 'nullable|boolean', 'email_verified' => 'nullable|boolean',
'active' => 'nullable|boolean' 'active' => 'nullable|boolean',
'phone_number' => 'nullable|string',
'company' => 'nullable|string',
]; ];
} }
@ -251,7 +252,9 @@ final class UserApiController extends APICRUDController {
'birthday' => 'nullable|date_format:U', 'birthday' => 'nullable|date_format:U',
'password' => 'sometimes|string|min:8|confirmed', 'password' => 'sometimes|string|min:8|confirmed',
'email_verified' => 'nullable|boolean', 'email_verified' => 'nullable|boolean',
'active' => 'nullable|boolean' 'active' => 'nullable|boolean',
'phone_number' => 'nullable|string',
'company' => 'nullable|string',
]; ];
} }

View File

@ -133,6 +133,8 @@ final class UserService extends OAuth2ProtectedService implements IUserService
$data[StandardClaims::Name] = $current_user->getFullName(); $data[StandardClaims::Name] = $current_user->getFullName();
$data[StandardClaims::GivenName] = $current_user->getFirstName(); $data[StandardClaims::GivenName] = $current_user->getFirstName();
$data[StandardClaims::FamilyName] = $current_user->getLastName(); $data[StandardClaims::FamilyName] = $current_user->getLastName();
$data[StandardClaims::PhoneNumber] = $current_user->getPhoneNumber();
$data[StandardClaims::PhoneNumberVerified] = false;
$data[StandardClaims::NickName] = $current_user->getIdentifier(); $data[StandardClaims::NickName] = $current_user->getIdentifier();
$data[StandardClaims::SubjectIdentifier] = $current_user->getAuthIdentifier(); $data[StandardClaims::SubjectIdentifier] = $current_user->getAuthIdentifier();
$data[StandardClaims::Picture] = $current_user->getPic(); $data[StandardClaims::Picture] = $current_user->getPic();
@ -146,6 +148,7 @@ final class UserService extends OAuth2ProtectedService implements IUserService
$data[StandardClaims::GitHubUser] = $current_user->getGithubUser(); $data[StandardClaims::GitHubUser] = $current_user->getGithubUser();
$data[StandardClaims::WeChatUser] = $current_user->getWechatUser(); $data[StandardClaims::WeChatUser] = $current_user->getWechatUser();
$data[StandardClaims::TwitterName] = $current_user->getTwitterName(); $data[StandardClaims::TwitterName] = $current_user->getTwitterName();
$data[StandardClaims::Company] = $current_user->getCompany();
$user_groups = []; $user_groups = [];

View File

@ -118,6 +118,12 @@ final class UserFactory
if(isset($payload['state'])) if(isset($payload['state']))
$user->setState(trim($payload['state'])); $user->setState(trim($payload['state']));
if(isset($payload['phone_number']))
$user->setPhoneNumber(trim($payload['phone_number']));
if(isset($payload['company']))
$user->setCompany(trim($payload['company']));
if(isset($payload['post_code'])) if(isset($payload['post_code']))
$user->setPostCode(trim($payload['post_code'])); $user->setPostCode(trim($payload['post_code']));

View File

@ -281,6 +281,18 @@ class User extends BaseEntity
*/ */
private $spam_type; private $spam_type;
/**
* @ORM\Column(name="company", nullable=true, type="string")
* @var string
*/
private $company;
/**
* @ORM\Column(name="phone_number", nullable=true, type="string")
* @var string
*/
private $phone_number;
// relations // relations
/** /**
@ -385,6 +397,8 @@ class User extends BaseEntity
$this->scope_groups = new ArrayCollection(); $this->scope_groups = new ArrayCollection();
$this->reset_password_requests = new ArrayCollection(); $this->reset_password_requests = new ArrayCollection();
$this->spam_type = self::SpamTypeNone; $this->spam_type = self::SpamTypeNone;
$this->company = null;
$this->phone_number = null;
} }
/** /**
@ -1665,5 +1679,36 @@ SQL;
return $this->spam_type == self::SpamTypeSpam; return $this->spam_type == self::SpamTypeSpam;
} }
/**
* @return string
*/
public function getCompany(): ?string
{
return $this->company;
}
/**
* @param string $company
*/
public function setCompany(string $company): void
{
$this->company = $company;
}
/**
* @return string
*/
public function getPhoneNumber(): ?string
{
return $this->phone_number;
}
/**
* @param string $phone_number
*/
public function setPhoneNumber(string $phone_number): void
{
$this->phone_number = $phone_number;
}
} }

View File

@ -195,4 +195,9 @@ abstract class StandardClaims
* WeChatUser * WeChatUser
*/ */
const WeChatUser = 'wechat_user'; const WeChatUser = 'wechat_user';
/**
* Company
*/
const Company = 'company';
} }

View File

@ -0,0 +1,51 @@
<?php namespace Database\Migrations;
/**
* Copyright 2020 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema as Schema;
use LaravelDoctrine\Migrations\Schema\Table;
use LaravelDoctrine\Migrations\Schema\Builder;
/**
* Class Version20200715150546
* @package Database\Migrations
*/
class Version20200715150546 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$builder = new Builder($schema);
if($schema->hasTable("users") && !$builder->hasColumn("users","company") ) {
$builder->table('users', function (Table $table) {
$table->string('company')->setNotnull(false);
$table->string('phone_number')->setNotnull(false);
});
}
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$builder = new Builder($schema);
if($schema->hasTable("users") && $builder->hasColumn("users","company") ) {
$builder->table('users', function (Table $table) {
$table->dropColumn('company');
$table->dropColumn('phone_number');
});
}
}
}

View File

@ -61,7 +61,7 @@ UsersCrud.prototype.constructor = UsersCrud;
UsersCrud.prototype._buildFilters = function () { UsersCrud.prototype._buildFilters = function () {
var term = encodeURIComponent(this.searchTerm); var term = encodeURIComponent(this.searchTerm);
return 'filter=first_name=@'+term+',last_name=@'+term+',email=@'+term; return 'filter=first_name=@'+term+',last_name=@'+term+',email=@'+term+',full_name=@'+term;
}; };
UsersCrud.prototype.init = function () { UsersCrud.prototype.init = function () {

View File

@ -157,12 +157,15 @@ BasicCrud.prototype = {
$('.label-info').show(); $('.label-info').show();
$('#table').hide(); $('#table').hide();
$('#search-container').hide(); $('#search-container').hide();
$('#pager-container').hide();
$('body').ajax_loader('stop'); $('body').ajax_loader('stop');
return; return;
} }
$('.label-info').hide(); $('.label-info').hide();
$('#table').show(); $('#table').show();
$('#search-container').show(); $('#search-container').show();
$('#pager-container').show();
var body = _this.templatePage.render(items, _this.directivesPage); var body = _this.templatePage.render(items, _this.directivesPage);
$('#body-table', '#table').remove(); $('#body-table', '#table').remove();
@ -204,7 +207,6 @@ BasicCrud.prototype = {
} }
} }
}; };
var pager = templatePager.render(pages, directivesPager); var pager = templatePager.render(pages, directivesPager);
$('#pager', '#pager-container').remove(); $('#pager', '#pager-container').remove();

View File

@ -139,6 +139,17 @@
</select> </select>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6">
<label for="city">Phone</label>
<input autocomplete="off" class="form-control" type="text" name="phone_number" id="phone_number"
value="{!! $user->phone_number !!}">
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6">
<label for="state">Company</label>
<input autocomplete="off" class="form-control" type="text" name="company" id="company"
value="{!! $user->company !!}">
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-12 col-lg-12"> <div class="form-group col-xs-10 col-sm-4 col-md-12 col-lg-12">
<label for="language">Language</label> <label for="language">Language</label>
<select id="language" class="form-control" name="language" value="{!! $user->language !!}" data-lpignore="true" autocomplete="off"> <select id="language" class="form-control" name="language" value="{!! $user->language !!}" data-lpignore="true" autocomplete="off">

View File

@ -151,7 +151,6 @@
value="{!! $user->address2 !!}"> value="{!! $user->address2 !!}">
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6"> <div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6">
<label for="city">City</label> <label for="city">City</label>
<input autocomplete="off" class="form-control" type="text" name="city" id="city" <input autocomplete="off" class="form-control" type="text" name="city" id="city"
@ -179,6 +178,17 @@
</select> </select>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6">
<label for="city">Phone</label>
<input autocomplete="off" class="form-control" type="text" name="phone_number" id="phone_number"
value="{!! $user->phone_number !!}">
</div>
<div class="form-group col-xs-10 col-sm-4 col-md-6 col-lg-6">
<label for="state">Company</label>
<input autocomplete="off" class="form-control" type="text" name="company" id="company"
value="{!! $user->company !!}">
</div>
<div class="clearfix"></div>
<div class="form-group col-xs-10 col-sm-4 col-md-12 col-lg-12"> <div class="form-group col-xs-10 col-sm-4 col-md-12 col-lg-12">
<label for="language">Language</label> <label for="language">Language</label>
<select id="language" class="form-control" name="language" <select id="language" class="form-control" name="language"