Plugin Directory

Changeset 2058533


Ignore:
Timestamp:
03/27/2019 07:56:14 PM (7 years ago)
Author:
rleon.uy
Message:

WP-17 The plugin shows invalid username / password when the password is blocked

WP-16 Improve feedback when you are blocked in wordpress

Location:
cyclos/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cyclos/trunk/cyclos-common.php

    r2058400 r2058533  
    5656        CyclosKey::add($result, 'errorInaccessibleChannel', 'Error message: inaccessible channel', 'Access denied. The channel used to connect to the server is not allowed or misconfigured');
    5757        CyclosKey::add($result, 'errorInaccessiblePrincipal', 'Error message: inaccessible principal', 'You cannot use your {principal} in this channel');
    58         CyclosKey::add($result, 'errorIndefinitelyBlocked', 'Error message: password indefinitely blocked', 'Your password has been disabled by exceeding the maximum of tries.\nPlease, contact the administration');
    59         CyclosKey::add($result, 'errorTemporarilyBlocked', 'Error message: password temporarily blocked', 'Your password has been blocked by exceeding the maximum of tries');
     58        CyclosKey::add($result, "errorUserBlocked", 'Error message: user blocked', 'Your access has been blocked. Please, contact the administration.');
     59        CyclosKey::add($result, "errorUserDisabled", 'Error message: user disabled', 'Your user account has been disabled. Please, contact the administration.');
     60        CyclosKey::add($result, "errorUserPending", 'Error message: pending user', 'Your user account is pending for activation. Please, contact the administration for more information.');
    6061        CyclosKey::add($result, "errorLogin", 'Error message: invalid login', 'Invalid username / password');
    61         CyclosKey::add($result, 'errorInvalidPassword', 'Error message: password invalid', 'The given user / password are incorrect. Please, try again');
     62        CyclosKey::add($result, 'errorPasswordIndefinitelyBlocked', 'Error message: password indefinitely blocked', 'Your password has been disabled by exceeding the maximum of tries.\nPlease, contact the administration');
     63        CyclosKey::add($result, 'errorPasswordTemporarilyBlocked', 'Error message: password temporarily blocked', 'Your password has been blocked by exceeding the maximum of tries');
     64        CyclosKey::add($result, 'errorInvalidPassword', 'Error message: password invalid', 'The given password is incorrect. Please, try again');
    6265        CyclosKey::add($result, "errorInvalidAccessClient", "Error message: invalid access client", "The current access client is not correctly configured");
    6366        CyclosKey::add($result, 'errorOperatorWithPendingAgreements', 'Error message: operator pending agreements', 'A required agreement needs to be accepted by your manager before you can login');       
     
    157160                // Likely a connection error (no REST API found)
    158161                $property = 'errorConnection';
    159             }                  
    160         } elseif (property_path_exists($e, 'error->code')) {       
     162            }       
     163        } elseif (property_path_exists($e, 'error->code')) {                   
    161164            // Conflict, forbidden or other errors which contains a 'code' attribute           
    162             $property = 'error'.ucwords($e->error->code);           
     165            if($e->error->code = 'login') {
     166                // Handle login error
     167                if(property_exists($e->error, 'passwordStatus')) {
     168                    // Password errors
     169                    $property = 'errorPassword'.ucwords($e->error->passwordStatus);
     170                } else if(property_exists($e->error, 'userStatus')) {
     171                    // User errors
     172                    $property = 'errorUser'.ucwords($e->error->userStatus);
     173                }
     174            }
     175            if($property == NULL) {
     176                $property = 'error'.ucwords($e->error->code);
     177            }
    163178        }
    164179    }
  • cyclos/trunk/cyclos-public.php

    r2058400 r2058533  
    6161    $authService = new Cyclos\AuthService();
    6262
    63     $out = '';
     63    $out = '<div id="alert" style="display: none;">
     64             <span class="closebtn" onclick="this.parentElement.style.display=\'none\';">&times;</span>
     65             <strong>Notice</strong> <span id="alertMessage"></span></div>';
     66   
    6467    $returnToValue = '';
    6568
     
    146149        $out = $out . '
    147150        <script>
    148             jQuery(document).ready(function($) {
     151            jQuery(document).ready(function($) {               
    149152        ';
    150153        $out = $out . '
    151                 $(".cyclosLoginForm").submit(function(event) {
     154               
     155                /**
     156                 * Shows a notification with type Error, Warning, Info
     157                 */
     158                function showNotification(message, type) {                 
     159                    $("#alertMessage").html(message);
     160                    $("#alert").show();                 
     161                    $("#alert").attr( "class", "alert"+type);
     162           
     163                     
     164                }
     165               
     166                function hideNotification() {
     167                    $("#alertMessage").html("");
     168                    $("#alert").hide();
     169                }
     170               
     171                $(".cyclosLoginForm").submit(function(event) {
    152172                    var submitEnabled = true;
    153173                    if (submitEnabled) {
     174                        hideNotification();
    154175                        var principal = this.cyclosPrincipal.value.trim();
    155176                        var password = this.cyclosPassword.value.trim();
     
    170191                                    if (response.redirectUrl) {
    171192                                        location.href = response.redirectUrl;                                       
    172                                     } else {
    173                                         alert(response.errorMessage || "Invalid data received from server");
    174                                         submitEnabled = true;
     193                                    } else {                                       
     194                                        showNotification(response.errorMessage || "Invalid data received from server", "Error");
     195                                        submitEnabled = true;
    175196                                    }
    176197                                })
     
    198219                function showLogin() {
    199220                    if (submitEnabled) {
     221                        hideNotification();
    200222                        $(".cyclosLoginForm").trigger("reset");
    201223                        $(".cyclosLoginContainer").show();
     
    206228               
    207229                function showForgotPassword() {
    208                     if (submitEnabled) {
    209                         $(".cyclosForgotPasswordForm").trigger("reset");
     230                    if (submitEnabled) {
     231                        hideNotification();
     232                        $(".cyclosForgotPasswordForm").trigger("reset");
    210233                        $(".cyclosLoginContainer").hide();
    211234                        $(".cyclosForgotContainer").show();
     
    235258                $(".cyclosForgotPasswordForm").submit(function(event) {
    236259                    if (submitEnabled) {
     260                       
     261                        hideNotification();
     262                           
    237263                        var email = this.cyclosEmail.value.trim();
    238264                        var captchaText = this.cyclosCaptcha.value.trim();
     
    252278                                    response = response || {};
    253279                                    if (response.errorMessage) {
    254                                         alert(response.errorMessage || "Invalid data received from server");
     280                                        showNotification(response.errorMessage || "Invalid data received from server", "Error");
    255281                                    } else {
    256282                                        captchaId = null;
    257283                                        showLogin();
    258                                         alert("' . $t->forgotDone . '".replace("{email}", email));
     284                                        showNotification("' . $t->forgotDone . '".replace("{email}", email), "Error");
    259285                                    }
    260286                                })
     
    308334                    sanitize_text_field($_POST['password']),
    309335                    $_SERVER['REMOTE_ADDR']);       
    310     } catch (\Exception $e) {       
     336    } catch (\Exception $e) {     
    311337        $errorMessage = handleError($e);
    312338    }
  • cyclos/trunk/stylesheet.css

    r2058400 r2058533  
    5151}
    5252
    53 .cyclosFormBox a:hover {
     53.cyclosFormBox a:hover,
     54.closebtn:hover {
    5455    color: #9cb7c3;
    5556}
     
    8990    margin: 7px 0 -5px;
    9091}
     92
     93#alert { 
     94    padding: 5px 10px;   
     95    color: #ffffff;
     96    width: 250px;
     97    margin: auto;
     98    font-family: "Open sans",Helvetica,Arial,Verdana,sans-serif;
     99    font-size: 15px;
     100    position: relative;
     101    -webkit-border-radius: 3px;
     102    border-radius: 3px;
     103}
     104
     105.alertError {
     106    background-color: #b00020;
     107}
     108
     109#alert strong {
     110    display: block;
     111}
     112
     113#alertMessage {
     114    display: inline-block;
     115    line-height: 18px;
     116}
     117
     118.closebtn {
     119    margin-left: 10px;
     120    color: white;
     121    font-weight: bold;
     122    position: absolute;
     123    font-size: 22px;
     124    cursor: pointer;
     125    transition: 0.3s;
     126    vertical-align: middle;
     127    line-height: 35px;
     128    right: 10px;
     129    top: 0px;
     130}
Note: See TracChangeset for help on using the changeset viewer.