
PUT /api/v1/users/me payload 'first_name' => 'sometimes|string', 'last_name' => 'sometimes|string', 'email' => 'sometimes|email', 'identifier' => 'sometimes|string', 'bio' => 'nullable|string', 'address1' => 'nullable|string', 'address2' => 'nullable|string', 'city' => 'nullable|string', 'state' => 'nullable|string', 'post_code' => 'nullable|string', 'country_iso_code' => 'nullable|country_iso_alpha2_code', 'second_email' => 'nullable|email', 'third_email' => 'nullable|email', 'gender' => 'nullable|string', 'gender_specify' => 'nullable|string', 'statement_of_interest' => 'nullable|string', 'irc' => 'nullable|string', 'linked_in_profile' => 'nullable|string', 'github_user' => 'nullable|string', 'wechat_user' => 'nullable|string', 'twitter_name' => 'nullable|string', 'language' => 'nullable|string', 'birthday' => 'nullable|date_format:U', 'password' => 'sometimes|string|min:8|confirmed', 'phone_number' => 'nullable|string', 'company' => 'nullable|string', required scopes me/write PUT /api/v1/users/me/pic multiform encoding pic: file (png, jpg, jpeg) required scopes me/write Change-Id: I31a1edd9eb1fcdee228a8f5ba1b44d324116edd9 Signed-off-by: smarcet <smarcet@gmail.com>
110 lines
3.6 KiB
PHP
110 lines
3.6 KiB
PHP
<?php namespace App\Providers;
|
|
/**
|
|
* Copyright 2015 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 App\Http\Utils\CountriesISOCodes;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Sokil\IsoCodes\IsoCodesFactory;
|
|
use Validators\CustomValidator;
|
|
use App\Http\Utils\Log\LaravelMailerHandler;
|
|
/**
|
|
* Class AppServiceProvider
|
|
* @package App\Providers
|
|
*/
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
|
|
$logger = Log::getLogger();
|
|
|
|
foreach($logger->getHandlers() as $handler) {
|
|
$handler->setLevel(Config::get('log.level', 'error'));
|
|
}
|
|
|
|
//set email log
|
|
$to = Config::get('log.to_email');
|
|
$from = Config::get('log.from_email');
|
|
|
|
if (!empty($to) && !empty($from)) {
|
|
$subject = Config::get('log.email_subject', 'openstackid-resource-server error');
|
|
$handler = new LaravelMailerHandler($to, $subject, $from);
|
|
$handler->setLevel(Config::get('log.email_level', 'error'));
|
|
$logger->pushHandler($handler);
|
|
}
|
|
|
|
Validator::resolver(function($translator, $data, $rules, $messages)
|
|
{
|
|
return new CustomValidator($translator, $data, $rules, $messages);
|
|
});
|
|
|
|
Validator::extend('country_iso_alpha2_code', function($attribute, $value, $parameters, $validator)
|
|
{
|
|
|
|
$validator->addReplacer('country_iso_alpha2_code', function($message, $attribute, $rule, $parameters) use ($validator) {
|
|
return sprintf("%s should be a valid country iso code", $attribute);
|
|
});
|
|
if(!is_string($value)) return false;
|
|
$value = trim($value);
|
|
|
|
$isoCodes = new IsoCodesFactory();
|
|
$countries = $isoCodes->getCountries();
|
|
$country = $countries->getByAlpha2($value);
|
|
|
|
return !is_null($country);
|
|
});
|
|
|
|
Validator::extend('openid.identifier', function($attribute, $value, $parameters, $validator)
|
|
{
|
|
$validator->addReplacer('openid.identifier', function($message, $attribute, $rule, $parameters) use ($validator) {
|
|
return sprintf("%s should be a valid openid identifier", $attribute);
|
|
});
|
|
|
|
return preg_match('/^(\w|\.)+$/', $value);
|
|
});
|
|
|
|
|
|
Validator::extend('int_array', function($attribute, $value, $parameters, $validator)
|
|
{
|
|
$validator->addReplacer('int_array', function($message, $attribute, $rule, $parameters) use ($validator) {
|
|
return sprintf("%s should be an array of integers", $attribute);
|
|
});
|
|
if(!is_array($value)) return false;
|
|
foreach($value as $element)
|
|
{
|
|
if(!is_integer($element)) return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//
|
|
}
|
|
}
|