Added mobile detection for create user form
* added lib https://github.com/jenssegers/agent to improve mobile agent detection, if we are on mobile, then use the mobile friendly creaate user form. * improved error message for non verified users Change-Id: I5c6987b6fdfd8260b97b11d3c9c57264791f502b
This commit is contained in:
parent
88dd2c708a
commit
6712150ad6
|
@ -22,4 +22,5 @@ doc/build
|
|||
*.egg
|
||||
*.egg-info
|
||||
public/bower_assets
|
||||
public/bower_assets/*
|
||||
public/bower_assets/*
|
||||
*.log
|
|
@ -20,6 +20,8 @@ use utils\services\IServerConfigurationService as IUtilsServerConfigurationServi
|
|||
use oauth2\services\IMementoOAuth2SerializerService;
|
||||
use oauth2\services\ISecurityContextService;
|
||||
use auth\exceptions\AuthenticationException;
|
||||
use auth\exceptions\UnverifiedEmailMemberException;
|
||||
|
||||
/**
|
||||
* Class UserController
|
||||
*/
|
||||
|
@ -191,9 +193,12 @@ final class UserController extends OpenIdController
|
|||
|
||||
public function postLogin()
|
||||
{
|
||||
$max_login_attempts_2_show_captcha = $this->server_configuration_service->getConfigValue("MaxFailed.LoginAttempts.2ShowCaptcha");
|
||||
$login_attempts = 0;
|
||||
$username = '';
|
||||
try
|
||||
{
|
||||
$max_login_attempts_2_show_captcha = $this->server_configuration_service->getConfigValue("MaxFailed.LoginAttempts.2ShowCaptcha");
|
||||
|
||||
$data = Input::all();
|
||||
|
||||
if(isset($data['username']))
|
||||
|
@ -257,8 +262,22 @@ final class UserController extends OpenIdController
|
|||
)
|
||||
);
|
||||
}
|
||||
catch(AuthenticationException $ex1){
|
||||
catch(UnverifiedEmailMemberException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->login_strategy->errorLogin
|
||||
(
|
||||
array
|
||||
(
|
||||
'max_login_attempts_2_show_captcha' => $max_login_attempts_2_show_captcha,
|
||||
'login_attempts' => $login_attempts,
|
||||
'username' => $username,
|
||||
'error_message' => $ex1->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
catch(AuthenticationException $ex2){
|
||||
Log::warning($ex2);
|
||||
return Redirect::action('UserController@getLogin');
|
||||
}
|
||||
catch (Exception $ex)
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace auth;
|
|||
use auth\exceptions\AuthenticationException;
|
||||
use auth\exceptions\AuthenticationInvalidPasswordAttemptException;
|
||||
use auth\exceptions\AuthenticationLockedUserLoginAttempt;
|
||||
use auth\exceptions\UnverifiedEmailMemberException;
|
||||
use Exception;
|
||||
use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserProviderInterface;
|
||||
|
@ -150,7 +151,7 @@ class CustomAuthProvider implements UserProviderInterface
|
|||
if(!$member->canLogin())
|
||||
{
|
||||
if(!$member->isEmailVerified())
|
||||
throw new AuthenticationException(sprintf("member %s is not verified yet!", $email));
|
||||
throw new UnverifiedEmailMemberException(sprintf("member %s is not verified yet!", $email));
|
||||
throw new AuthenticationException(sprintf("member %s does not exists!", $email));
|
||||
}
|
||||
|
||||
|
@ -191,6 +192,11 @@ class CustomAuthProvider implements UserProviderInterface
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
catch(UnverifiedEmailMemberException $ex1){
|
||||
$checkpoint_service->trackException($ex1);
|
||||
$log_service->warning($ex1);
|
||||
throw $ex1;
|
||||
}
|
||||
catch (Exception $ex)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright 2016 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.
|
||||
**/
|
||||
|
||||
namespace auth\exceptions;
|
||||
|
||||
/**
|
||||
* Class UnverifiedEmailMemberException
|
||||
* @package auth\exceptions
|
||||
*/
|
||||
class UnverifiedEmailMemberException extends \Exception
|
||||
{
|
||||
public function __construct($message = "")
|
||||
{
|
||||
parent::__construct($message, 0, null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright 2016 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.
|
||||
**/
|
||||
|
||||
namespace services\facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class ExternalUrlService extends Facade {
|
||||
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'externalurlservice';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright 2016 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.
|
||||
**/
|
||||
|
||||
namespace services\utils;
|
||||
|
||||
use Jenssegers\Agent\Agent;
|
||||
use services\facades\ServerConfigurationService;
|
||||
|
||||
|
||||
/**
|
||||
* Class ExternalUrlService
|
||||
* @package services\utils
|
||||
*/
|
||||
final class ExternalUrlService
|
||||
{
|
||||
public function getCreateAccountUrl(){
|
||||
$agent = new Agent();
|
||||
$path = $agent->isMobile() ? 'join/register/mobile/community' : 'join/register';
|
||||
$url = sprintf("%s%s",ServerConfigurationService::getConfigValue("Assets.Url"),$path);
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function getVerifyAccountUrl(){
|
||||
$url = ServerConfigurationService::getConfigValue("Assets.Url").'members/verification/resend';
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function getForgotPasswordUrl(){
|
||||
$url = ServerConfigurationService::getConfigValue("Assets.Url").'Security/lostpassword';
|
||||
return $url;
|
||||
}
|
||||
}
|
|
@ -28,10 +28,15 @@ class UtilsProvider extends ServiceProvider {
|
|||
return new ServerConfigurationService(App::make(UtilsServiceCatalog::CacheService),App::make(UtilsServiceCatalog::TransactionService));
|
||||
});
|
||||
|
||||
$this->app['externalurlservice'] = App::share(function ($app) {
|
||||
return new ExternalUrlService();
|
||||
});
|
||||
|
||||
// Shortcut so developers don't need to add an Alias in app/config/app.php
|
||||
App::booting(function () {
|
||||
$loader = AliasLoader::getInstance();
|
||||
$loader->alias('ServerConfigurationService', 'services\\facades\\ServerConfigurationService');
|
||||
$loader->alias('ExternalUrlService', 'services\\facades\\ExternalUrlService');
|
||||
});
|
||||
|
||||
App::singleton(UtilsServiceCatalog::LogService, 'services\\utils\\LogService');
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
</div>
|
||||
<div class="row" style="padding-top: 5px;padding-bottom: 5px;">
|
||||
<div class="col-md-12">
|
||||
<a href="{{ ServerConfigurationService::getConfigValue("Assets.Url") }}join/register"
|
||||
class="btn btn-default btn-md active">Register for an OpenStack ID</a>
|
||||
<a href="{{ ExternalUrlService::getCreateAccountUrl() }}" class="btn btn-default btn-md active">Register for an OpenStack ID</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -53,23 +53,18 @@
|
|||
</div>
|
||||
<div style="clear:both;padding-top:15px;" class="row">
|
||||
<div class="col-md-12">
|
||||
<a title="forgot password"
|
||||
href="{{ ServerConfigurationService::getConfigValue("Assets.Url") }}Security/lostpassword">Forgot
|
||||
password?</a>
|
||||
<a title="forgot password" target="_blank" href="{{ ExternalUrlService::getForgotPasswordUrl() }}">Forgot password?</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear:both;padding-top:15px;" class="row">
|
||||
<div class="col-md-12">
|
||||
<a title="register new account"
|
||||
href="{{ ServerConfigurationService::getConfigValue("Assets.Url") }}join/register">Register
|
||||
for an OpenStack ID</a>
|
||||
<a title="register new account" target="_blank" href="{{ ExternalUrlService::getCreateAccountUrl() }}">Register for an OpenStack ID</a>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear:both;padding-top:15px;" class="row">
|
||||
<div class="col-md-12">
|
||||
<a title="verify account"
|
||||
href="{{ ServerConfigurationService::getConfigValue("Assets.Url") }}members/verification/resend">Verify OpenStack ID</a>
|
||||
<a title="verify account" target="_blank" href="{{ ExternalUrlService::getVerifyAccountUrl() }}">Verify OpenStack ID</a>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
"way/laravel-test-helpers": "dev-master",
|
||||
"guzzlehttp/guzzle": "3.8.1",
|
||||
"smarcet/jose4php": "dev-master",
|
||||
"glenscott/url-normalizer" : "1.4.0"
|
||||
"glenscott/url-normalizer" : "1.4.0",
|
||||
"jenssegers/agent": "^2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "2.*",
|
||||
|
@ -71,4 +72,4 @@
|
|||
},
|
||||
"prefer-stable": true,
|
||||
"minimum-stability": "stable"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue