close #42 form validation error for multiple API Key information (PDO "dublicate" value)
This commit is contained in:
@@ -273,21 +273,34 @@ class Controller {
|
||||
}
|
||||
|
||||
if($f3->get('AJAX')){
|
||||
// error on ajax call
|
||||
header('Content-type: application/json');
|
||||
|
||||
// error on ajax call
|
||||
$errorData = [
|
||||
'status' => $f3->get('ERROR.status'),
|
||||
'code' => $f3->get('ERROR.code'),
|
||||
'text' => $f3->get('ERROR.text')
|
||||
];
|
||||
$return = (object) [];
|
||||
$error = (object) [];
|
||||
$error->type = 'error';
|
||||
$error->code = $f3->get('ERROR.code');
|
||||
$error->status = $f3->get('ERROR.status');
|
||||
$error->message = $f3->get('ERROR.text');
|
||||
|
||||
// append stack trace for greater debug level
|
||||
if( $f3->get('DEBUG') === 3){
|
||||
$errorData['trace'] = $f3->get('ERROR.trace');
|
||||
$error->trace = $f3->get('ERROR.trace');
|
||||
}
|
||||
|
||||
echo json_encode($errorData);
|
||||
// check if error is a PDO Exception
|
||||
if(strpos(strtolower( $f3->get('ERROR.text') ), 'duplicate') !== false){
|
||||
preg_match_all('/\'([^\']+)\'/', $f3->get('ERROR.text'), $matches, PREG_SET_ORDER);
|
||||
|
||||
if(count($matches) === 2){
|
||||
$error->field = $matches[1][1];
|
||||
$error->message = 'Value "' . $matches[0][1] . '" already exists';
|
||||
}
|
||||
}
|
||||
|
||||
$return->error[] = $error;
|
||||
|
||||
echo json_encode($return);
|
||||
}else{
|
||||
echo $f3->get('ERROR.text');
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ STATUS = 1
|
||||
MSG_DISABLED = "User registration is currently not allowed"
|
||||
|
||||
; use the invite system e.g. beta testing. A "registration key" is required (0=disabled, 1=enabled)
|
||||
INVITE = 1
|
||||
INVITE = 0
|
||||
|
||||
; the limit of registration keys. Increase it to hand out more keys
|
||||
INVITE_LIMIT = 50
|
||||
|
||||
@@ -309,24 +309,11 @@ define([
|
||||
if(jqXHR.responseText){
|
||||
var errorObj = $.parseJSON(jqXHR.responseText);
|
||||
|
||||
if(errorObj.text !== undefined){
|
||||
// DB error
|
||||
|
||||
if(errorObj.text.match('Duplicate')){
|
||||
// duplicate DB key
|
||||
|
||||
var fieldName = 'name';
|
||||
if(errorObj.text.match( fieldName )){
|
||||
// name exist
|
||||
form.showFormMessage([{type: 'error', message: 'Username already exists', field: fieldName}]);
|
||||
}
|
||||
|
||||
fieldName = 'email';
|
||||
if(errorObj.text.match( fieldName )){
|
||||
// email exist
|
||||
form.showFormMessage([{type: 'error', message: 'Email already exists', field: fieldName}]);
|
||||
}
|
||||
}
|
||||
if(
|
||||
errorObj.error &&
|
||||
errorObj.error.length > 0
|
||||
){
|
||||
form.showFormMessage(errorObj.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -224,7 +224,7 @@
|
||||
<blockquote>
|
||||
<p>
|
||||
API Key(s) are required to use <em class="pf-brand">pathfinder</em>.
|
||||
Don't have one? - Create a new key with the lowest access level possible.
|
||||
Don't have one? - Create a new key with an empty 'Access Mask'.
|
||||
</p>
|
||||
<small>Get your new/custom API Key from
|
||||
<a href="https://support.eveonline.com/api" target="_blank">here</a>
|
||||
@@ -270,6 +270,11 @@
|
||||
</div>
|
||||
{{/userData.api}}
|
||||
|
||||
<div class="{{formErrorContainerClass}} alert alert-danger" style="display: none;">
|
||||
<span class="txt-color txt-color-danger">Error</span>
|
||||
<small> (important non-critical information)</small>
|
||||
</div>
|
||||
|
||||
<div class="{{formWarningContainerClass}} alert alert-warning" style="display: none;">
|
||||
<span class="txt-color txt-color-warning">Warning</span>
|
||||
<small> (important non-critical information)</small>
|
||||
|
||||
@@ -95,12 +95,12 @@
|
||||
}
|
||||
|
||||
// show add button only on last row
|
||||
.pf-dialog-api-row:not(:nth-last-child(2)) .pf-dialog-clone-button{
|
||||
.pf-dialog-api-row:not(:nth-last-child(3)) .pf-dialog-clone-button{
|
||||
display: none;
|
||||
}
|
||||
|
||||
// hide delete button if there is just a single api row
|
||||
.pf-dialog-api-row:nth-child(2):nth-last-child(2) .pf-dialog-delete-button{
|
||||
.pf-dialog-api-row:nth-child(2):nth-last-child(3) .pf-dialog-delete-button{
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user