Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/Http/Controllers/Factories/UserValidationRulesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static function build(array $data, $update = false, ?User $currentUser =
'public_profile_show_photo' => 'sometimes|boolean',
'public_profile_show_fullname' => 'sometimes|boolean',
'public_profile_show_email' => 'sometimes|boolean',
'public_profile_allow_chat_with_me' => 'sometimes|boolean',
];

if(!is_null($currentUser) && !$currentUser->isAdmin() && $currentUser->hasPasswordSet()){
Expand Down Expand Up @@ -108,6 +109,7 @@ public static function build(array $data, $update = false, ?User $currentUser =
'public_profile_show_photo' => 'sometimes|boolean',
'public_profile_show_fullname' => 'sometimes|boolean',
'public_profile_show_email' => 'sometimes|boolean',
'public_profile_allow_chat_with_me' => 'sometimes|boolean',
];
}
}
3 changes: 3 additions & 0 deletions app/libs/Auth/Factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ public static function populate(User $user, array $payload):User{
if(isset($payload['public_profile_show_email']))
$user->setPublicProfileShowEmail(boolval($payload['public_profile_show_email']));

if(isset($payload['public_profile_allow_chat_with_me']))
$user->setPublicProfileAllowChatWithMe(boolval($payload['public_profile_allow_chat_with_me']));

if(isset($payload['email_verified']) && boolval($payload['email_verified']) === true && !$user->isEmailVerified()) {
// we have this variable to bypass email UserEmailVerified
$send_email_verified_notice = isset($payload['send_email_verified_notice']) ? boolval($payload['send_email_verified_notice']):true;
Expand Down
23 changes: 23 additions & 0 deletions app/libs/Auth/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ class User extends BaseEntity
*/
private $public_profile_show_email;

/**
* @ORM\Column(name="public_profile_allow_chat_with_me", options={"default":0}, type="boolean")
* @var bool
*/
private $public_profile_allow_chat_with_me;

/**
* @ORM\Column(name="last_login_date", type="datetime")
* @var \DateTime
Expand Down Expand Up @@ -417,6 +423,7 @@ public function __construct()
$this->public_profile_show_photo = false;
$this->public_profile_show_email = false;
$this->public_profile_show_fullname = false;
$this->public_profile_allow_chat_with_me = false;
$this->password = "";
$this->identifier = null;
$this->gender_specify = "";
Expand Down Expand Up @@ -984,6 +991,22 @@ public function setPublicProfileShowEmail(bool $public_profile_show_email): void
$this->public_profile_show_email = $public_profile_show_email;
}

/**
* @return bool
*/
public function isPublicProfileAllowChatWithMe(): bool
{
return $this->public_profile_allow_chat_with_me;
}

/**
* @param bool $public_profile_allow_chat_with_me
*/
public function setPublicProfileAllowChatWithMe(bool $public_profile_allow_chat_with_me): void
{
$this->public_profile_allow_chat_with_me = $public_profile_allow_chat_with_me;
}

/**
* @return \DateTime|null
*/
Expand Down
47 changes: 26 additions & 21 deletions app/libs/OAuth2/Responses/OAuth2AccessTokenValidationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
use OAuth2\Models\IClient;
use OAuth2\OAuth2Protocol;
use Utils\Http\HttpContentType;

/**
* Class OAuth2AccessTokenValidationResponse
* @package OAuth2\Responses
*/
class OAuth2AccessTokenValidationResponse extends OAuth2DirectResponse {
class OAuth2AccessTokenValidationResponse extends OAuth2DirectResponse
{

/**
* @param array|int $access_token
Expand All @@ -48,40 +50,43 @@ public function __construct
// Successful Responses: A server receiving a valid request MUST send a
// response with an HTTP status code of 200.
parent::__construct(self::HttpOkResponse, HttpContentType::Json);
$this[OAuth2Protocol::OAuth2Protocol_AccessToken] = $access_token;
$this[OAuth2Protocol::OAuth2Protocol_ClientId] = $client->getClientId();
$this['application_type'] = $client->getApplicationType();
$this[OAuth2Protocol::OAuth2Protocol_TokenType] = 'Bearer';
$this[OAuth2Protocol::OAuth2Protocol_Scope] = $scope;
$this[OAuth2Protocol::OAuth2Protocol_Audience] = $audience;
$this[OAuth2Protocol::OAuth2Protocol_AccessToken] = $access_token;
$this[OAuth2Protocol::OAuth2Protocol_ClientId] = $client->getClientId();
$this['application_type'] = $client->getApplicationType();
$this[OAuth2Protocol::OAuth2Protocol_TokenType] = 'Bearer';
$this[OAuth2Protocol::OAuth2Protocol_Scope] = $scope;
$this[OAuth2Protocol::OAuth2Protocol_Audience] = $audience;
$this[OAuth2Protocol::OAuth2Protocol_AccessToken_ExpiresIn] = $expires_in;

if(!is_null($user))
{
if (!is_null($user)) {
// user info if present
$this[OAuth2Protocol::OAuth2Protocol_UserId] = $user->getId();
$this['user_identifier'] = $user->getIdentifier();
$this['user_email'] = $user->getEmail();
$this['user_first_name'] = $user->getFirstName();
$this['user_last_name'] = $user->getLastName();
$this['user_language'] = $user->getLanguage();
$this['user_country'] = $user->getCountry();
$this['user_email_verified'] = $user->isEmailVerified();
$this['user_pic'] = $user->getPic();
$this['user_identifier'] = $user->getIdentifier();
$this['user_email'] = $user->getEmail();
$this['user_first_name'] = $user->getFirstName();
$this['user_last_name'] = $user->getLastName();
$this['user_language'] = $user->getLanguage();
$this['user_country'] = $user->getCountry();
$this['user_email_verified'] = $user->isEmailVerified();
$this['user_pic'] = $user->getPic();
$this["user_public_profile_show_fullname"] = $user->isPublicProfileShowFullname();
$this['user_public_profile_show_email'] = $user->isPublicProfileShowEmail();
$this['user_public_profile_show_photo'] = $user->isPublicProfileShowPhoto();
$this['user_public_profile_allow_chat_with_me'] = $user->isPublicProfileAllowChatWithMe();
// default empty value
$user_groups = [];
foreach ($user->getGroups() as $group){
$user_groups = [];
foreach ($user->getGroups() as $group) {
$user_groups[] = SerializerRegistry::getInstance()->getSerializer($group)->serialize();
}

$this['user_groups'] = $user_groups;
}

if(count($allowed_urls)){
if (count($allowed_urls)) {
$this['allowed_return_uris'] = implode(' ', $allowed_urls);
}

if(count($allowed_origins)){
if (count($allowed_origins)) {
$this['allowed_origins'] = implode(' ', $allowed_origins);
}
}
Expand Down
49 changes: 49 additions & 0 deletions database/migrations/Version20210916210607.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php namespace Database\Migrations;
/**
* Copyright 2021 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\Builder;
use LaravelDoctrine\Migrations\Schema\Table;
/**
* Class Version20210916210607
* @package Database\Migrations
*/
class Version20210916210607 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
$builder = new Builder($schema);
if($schema->hasTable("users") && !$builder->hasColumn("users","public_profile_allow_chat_with_me") ) {
$builder->table('users', function (Table $table) {
$table->boolean('public_profile_allow_chat_with_me')->setNotnull(false)->setDefault(false);
});
}
}

/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{
$builder = new Builder($schema);
if($schema->hasTable("users") && $builder->hasColumn("users","public_profile_allow_chat_with_me") ) {
$builder->table('users', function (Table $table) {
$table->dropColumn('public_profile_allow_chat_with_me');
});
}
}
}
9 changes: 9 additions & 0 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@
/>&nbsp;Show Email on Public Profile?
</label>
</div>
<div class="checkbox col-xs-10 col-sm-4 col-md-12 col-lg-12">
<label>
<input type="checkbox" id="public_profile_allow_chat_with_me" name="public_profile_allow_chat_with_me"
@if($user->public_profile_allow_chat_with_me)
checked
@endif
/>&nbsp;Allow people to chat with me?
</label>
</div>
<button type="submit" class="btn btn-default btn-lg btn-primary">Save</button>
<input type="hidden" name="id" id="id" value="{!! $user->id !!}"/>
</form>
Expand Down