Plugin Directory

Changeset 1951036


Ignore:
Timestamp:
10/03/2018 06:41:18 PM (7 years ago)
Author:
augusto1995
Message:

Added support to go to a specific page after successfull login

Location:
cyclos/trunk
Files:
2 edited

Legend:

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

    r1809299 r1951036  
    6969
    7070    if ($showForgotPassword) {
     71        $returnToValue = "";
     72        if(isset($_GET["returnTo"])){
     73            $returnToValue = $_GET["returnTo"];
     74        }
    7175        $out = $out . '
    7276            <div class="cyclosFormBox cyclosForgotContainer" style="display:none">
     
    99103            <form class="cyclosLoginForm" action="#" method="post">
    100104                <div class="cyclosFormTitle">' . $t->loginTitle . '</div>
     105                <div>
     106                    <input name="cyclosReturn" value="'. $returnToValue .'" type="hidden">
     107                </div>
    101108                <div class="cyclosFormField">
    102109                    <input placeholder="' . $t->loginName . '" name="cyclosPrincipal" type="text" required>
     
    131138                        var principal = this.cyclosPrincipal.value.trim();
    132139                        var password = this.cyclosPassword.value.trim();
     140                        var returnTo = this.cyclosReturn.value.trim();
    133141                       
    134142                        if (principal != "" && password != "") {
    135143                            var data = {
    136144                                "principal": principal,
    137                                 "password": password
     145                                "password": password,
     146                                "returnTo": returnTo
    138147                            }
    139148
     
    144153                                    response = response || {};
    145154                                    if (response.redirectUrl) {
    146                                         location.href = response.redirectUrl;
     155                                        var redirect = response.redirectUrl;
     156                                        if(response.returnTo && response.returnTo !== ""){
     157                                            redirect += "&returnTo=" + encodeURIComponent(response.returnTo);
     158                                        }
     159                                        location.href = redirect;
    147160                                    } else {
    148161                                        alert(response.errorMessage || "Invalid data received from server");
     
    279292        $params->user = array("principal" => sanitize_text_field($_POST["principal"]));
    280293        $params->password = sanitize_text_field($_POST["password"]);
     294        $returnTo = $_POST["returnTo"];
    281295        $params->remoteAddress = $_SERVER['REMOTE_ADDR'];
    282296        $result = $loginService->loginUser($params);
     
    300314        }
    301315    }
    302    
    303316    // Get the redirect url if there were no errors
    304317    if (!empty($result)) {
     
    309322    $response = array(
    310323        "redirectUrl" => $redirectUrl,
     324        "returnTo" => $returnTo,
    311325        "errorMessage" => $errorMessage
    312326    );
  • cyclos/trunk/readme.txt

    r1809314 r1951036  
    55Requires at least: 4.3
    66Tested up to: 4.9.2
    7 Stable tag: 1.1.5
     7Stable tag: 1.1.6
    88License: GPLv2
    99
     
    3434
    3535== Changelog ==
     36= 1.1.6 - 2018-10-03 =
     37We added support to go to a specific page in Cyclos instead of the home after a successfully login.
     38
    3639= 1.1.5 - 2018-01-25 =
    3740We updated the plugin to be compatible with PHP 7.2.
Note: See TracChangeset for help on using the changeset viewer.