Fix on login error messages (OAUTH2/OIDC)

* fixed error on showing error message on login for OIDC flow
* improved error location
* added required validation for both fields ( user name, password)

Change-Id: Idefa98fa8739ad590e6811fcec8f1b146a5205f0
This commit is contained in:
Sebastian Marcet 2016-04-03 16:59:20 -03:00
parent 4378864929
commit c76f333c23
3 changed files with 30 additions and 27 deletions

View File

@ -53,12 +53,12 @@ class DisplayResponseUserAgentStrategy implements IDisplayResponseStrategy
->with('max_login_attempts_2_show_captcha', $data['max_login_attempts_2_show_captcha'])
->with('login_attempts', $data['login_attempts']);
if(isset($params['username']))
$response= $response->with('username', $params['username']);
if(isset($params['error_message']))
$response = $response->with('flash_notice', $params['error_message']);
if(isset($params['validator']))
$response = $response->withErrors($params['validator']);
if(isset($data['username']))
$response= $response->with('username', $data['username']);
if(isset($data['error_message']))
$response = $response->with('flash_notice', $data['error_message']);
if(isset($data['validator']))
$response = $response->withErrors($data['validator']);
return $response;
}

View File

@ -6,8 +6,6 @@
<meta http-equiv="X-XRDS-Location" content="{{ URL::action("DiscoveryController@idp")}}" />
@append
@section('content')
<h4 style="margin-left: 15px;">Please use your OpenStack ID to log in</h4>
@if(isset($identity_select))
<legend style="margin-left: 15px;">
@if(!$identity_select)
@ -17,17 +15,29 @@
@endif
</legend>
@endif
<div class="col-md-4" id="sidebar">
<div class="well">
{{ Form::open(array('id'=>'login_form','url' => URL::action('UserController@postLogin'), 'method' => 'post', "autocomplete" => "off")) }}
<legend>Login</legend>
<legend>Welcome&nbsp;to&nbsp;OpenStackId!&nbsp;<span aria-hidden="true" style="font-size: 10pt;" class="glyphicon glyphicon-info-sign pointable" title="Please use your OpenStack ID to log in"></span></legend>
<div class="form-group">
{{ Form::text('username',Session::has('username')? Session::get('username'):null, array('placeholder' => 'Username','class'=>'form-control')) }}
{{ Form::email('username',Session::has('username')? Session::get('username'):null, array
(
'placeholder' => 'Username',
'class' =>'form-control',
'required' => 'true'
)) }}
</div>
<div class="form-group">
{{ Form::password('password', array('placeholder' => 'Password','class'=>'form-control')) }}
{{ Form::password('password', array('placeholder' => 'Password', 'class' => 'form-control', 'required' => 'true')) }}
</div>
<div class="form-group">
@if(Session::has('flash_notice'))
<span class="error-message"><i class="fa fa-exclamation-triangle">&nbsp;{{ Session::get('flash_notice') }}</i></span>
@else
@foreach($errors->all() as $message)
<span class="error-message"><i class="fa fa-exclamation-triangle">&nbsp;{{ $message }}</i></span>
@endforeach
@endif
</div>
@if(Session::has('login_attempts') && Session::has('max_login_attempts_2_show_captcha') && Session::get('login_attempts') > Session::get('max_login_attempts_2_show_captcha'))
{{ Form::captcha(array('id'=>'captcha','class'=>'input-block-level')) }}
@ -35,6 +45,7 @@
@else
{{ Form::hidden('login_attempts', '0') }}
@endif
<div class="checkbox">
<label class="checkbox">
{{ Form::checkbox('remember', '1', false) }}Remember me
@ -55,7 +66,6 @@
<div class="col-md-12">
<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">
@ -70,19 +80,7 @@
</fieldset>
{{ Form::close() }}
</div>
@if(Session::has('flash_notice'))
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ Session::get('flash_notice') }}
</div>
@else
@foreach($errors->all() as $message)
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{ $message }}
</div>
@endforeach
@endif
</div>
<div class="col-md-8">
</div>

View File

@ -198,4 +198,9 @@ textarea {
.auto-width
{
width: auto !important;
}
.error-message
{
color:#c40022;
}