Plugin Directory

Changeset 2655014


Ignore:
Timestamp:
01/10/2022 06:30:05 AM (4 years ago)
Author:
mojoauth
Message:
  • Localization with 5 languages
  • Handle magic link redirection
Location:
mojoauth/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • mojoauth/trunk/admin/assets/css/style.css

    r2593508 r2655014  
    4141    color: red;
    4242}
     43.mojoauth_help_text {
     44    margin-left: 21%;
     45}
  • mojoauth/trunk/admin/assets/images/logo.svg

    r2593508 r2655014  
    1 <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 205.23 63.06"><defs><style>.cls-1{fill:#f9917a;}.cls-2{fill:#fff;}</style></defs><path d="M47,55.52c-3.45,0-6-1-7.69-2.92s-2.52-4.74-2.52-8.35q0-5.76,2.61-8.45c1.73-1.8,4.24-2.69,7.52-2.69a11.72,11.72,0,0,1,5.8,1.29,7.89,7.89,0,0,1,3.39,3.79,15.08,15.08,0,0,1,1.1,6.06q0,5.39-2.65,8.32T47,55.52Zm0-3.77a5.56,5.56,0,0,0,3.43-1,5.26,5.26,0,0,0,1.84-2.64,12,12,0,0,0,.57-3.9,12.16,12.16,0,0,0-.59-4.11,4.76,4.76,0,0,0-1.86-2.48A6.16,6.16,0,0,0,47,36.84a5.77,5.77,0,0,0-3.39.89,4.77,4.77,0,0,0-1.82,2.54,12.58,12.58,0,0,0-.55,4,9.92,9.92,0,0,0,1.31,5.51Q43.84,51.76,47,51.75Z" transform="translate(0 0)"/><path d="M63.53,55.56a5.56,5.56,0,0,1-.34,2.08A2.17,2.17,0,0,1,62,58.86a5.86,5.86,0,0,1-2.38.39v3.81a12.23,12.23,0,0,0,4.47-.74A5.75,5.75,0,0,0,67,60a8.14,8.14,0,0,0,1-4.31v-22H63.53Z" transform="translate(0 0)"/><path d="M83.49,55.52c-3.45,0-6-1-7.69-2.92s-2.52-4.74-2.52-8.35c0-3.84.86-6.66,2.6-8.45s4.25-2.69,7.52-2.69a11.73,11.73,0,0,1,5.81,1.29,7.87,7.87,0,0,1,3.38,3.79,14.91,14.91,0,0,1,1.11,6.06c0,3.59-.89,6.36-2.65,8.32S86.76,55.52,83.49,55.52Zm0-3.77a5.6,5.6,0,0,0,3.44-1,5.32,5.32,0,0,0,1.84-2.64,12.22,12.22,0,0,0,.57-3.9,12.41,12.41,0,0,0-.59-4.11,4.78,4.78,0,0,0-1.87-2.48,6.12,6.12,0,0,0-3.39-.82,5.71,5.71,0,0,0-3.38.89,4.84,4.84,0,0,0-1.83,2.54,12.88,12.88,0,0,0-.55,4A9.91,9.91,0,0,0,79,49.76Q80.31,51.76,83.44,51.75Z" transform="translate(0 0)"/><path d="M112.43,26.63h-5l-11,28.25h4.66l2.79-7.67h11.54l2.79,7.67h4.91ZM105.26,43.4l4.38-12.14,4.41,12.14Z" transform="translate(0 0)"/><path d="M136.4,55.52a12.15,12.15,0,0,1-5-1,7.12,7.12,0,0,1-3.24-2.86A9.13,9.13,0,0,1,127,47V33.62h4.44V46.33a5.73,5.73,0,0,0,1.21,4,6.1,6.1,0,0,0,7.5,0,5.73,5.73,0,0,0,1.21-4V33.62h4.28V47c0,2.83-.82,5-2.44,6.4A9.89,9.89,0,0,1,136.4,55.52Z" transform="translate(0 0)"/><path d="M159.49,55.43a6.47,6.47,0,0,1-4.55-1.52,5.76,5.76,0,0,1-1.68-4.49V37.3h-3.43V33.62h3.43V27.68h4.58v5.94H163V37.3h-5.17V48.53a3.75,3.75,0,0,0,.53,2.22,2.25,2.25,0,0,0,2,.74,5.48,5.48,0,0,0,1.44-.19,5,5,0,0,0,1.23-.48v3.94a7.55,7.55,0,0,1-1.72.5A9.66,9.66,0,0,1,159.49,55.43Z" transform="translate(0 0)"/><path d="M187,41.71V54.88h-4.45V42.27a5.72,5.72,0,0,0-1.24-4A4.59,4.59,0,0,0,177.64,37a9.17,9.17,0,0,0-2.58.35,15,15,0,0,0-2.44,1l0,16.53h-4.41V24.62h4.44V34.93a16.06,16.06,0,0,1,2.37-1.1,12,12,0,0,1,3.92-.67,10,10,0,0,1,4.27.85,6.25,6.25,0,0,1,2.75,2.75A10.4,10.4,0,0,1,187,41.71Z" transform="translate(0 0)"/><path d="M29.38,23.36q-1.21-.32-2.61-.57l0-.16v0c-.12-.69-.43-1.83-1-3.73-.83-2.92-2-6.93-3-11.71a3.36,3.36,0,0,1,.43-2.77c1.23-1.81,4.32-2.31,5.46-2.5a3.41,3.41,0,0,1,.4-.07c.64-.14.72-.57.72-.76A.77.77,0,0,0,29.12.3h-.07l0,0c-3.27-.29-6.36-.55-9,.26-3,.9-5,3.06-6.41,6.81L8,22.67l-.1.15c-.85.16-1.66.35-2.42.54C1.83,24.31,0,25.62,0,27.21c0,1.32,1.26,2.45,3.76,3.35V54.87H8.28V33.37l9,13,9.43-13V54.87h4.66V30.42c2.27-.87,3.41-2,3.41-3.21C34.82,25.62,33,24.31,29.38,23.36ZM17.53,39.73l-5.11-7.54c1.59.13,3.28.2,5,.2s3.67-.08,5.39-.23Z" transform="translate(0 0)"/><path class="cls-1" d="M204.7,49.33a2.78,2.78,0,0,0-.95-1.3,2.82,2.82,0,0,0-1.7-.46,2.71,2.71,0,0,0-1.34.31,2.45,2.45,0,0,0-.81.89,3.66,3.66,0,0,0-.28.56,1.12,1.12,0,0,1-.25-.35,3.69,3.69,0,0,0-.64-.6,2,2,0,0,0-1.09-.25,2.84,2.84,0,0,0-1.45.36,2.72,2.72,0,0,0-.95,1.12,5.22,5.22,0,0,0-.32,2v3.74H205V51.24A6.29,6.29,0,0,0,204.7,49.33Zm-5.58,4.34h-2.79V51.52a2.2,2.2,0,0,1,.32-1.23,1.21,1.21,0,0,1,1.13-.5,1.36,1.36,0,0,1,.85.25,1.13,1.13,0,0,1,.39.6,2.78,2.78,0,0,1,.1.78Zm4.49,0h-3.15V51.31a4.59,4.59,0,0,1,0-.74,2.39,2.39,0,0,1,.21-.67,1.35,1.35,0,0,1,.46-.46,1.79,1.79,0,0,1,.81-.18,1.82,1.82,0,0,1,1,.28,1.43,1.43,0,0,1,.46.75,3,3,0,0,1,.14,1Z" transform="translate(0 0)"/><path class="cls-1" d="M205.09,40.89a11.27,11.27,0,0,0-.39-1.2h-1.45c.07.18.18.43.29.67s.14.53.21.82a4,4,0,0,1,.1,1,2.11,2.11,0,0,1-.67,1.73,2.53,2.53,0,0,1-1.62.6V39.13a7.34,7.34,0,0,0-2.26.32,3.06,3.06,0,0,0-1.52,1.09,3.82,3.82,0,0,0,.46,4.59,4.5,4.5,0,0,0,3,.92,4.63,4.63,0,0,0,2.19-.46,2.94,2.94,0,0,0,1.34-1.27,4.09,4.09,0,0,0,.46-1.94A9.8,9.8,0,0,0,205.09,40.89Zm-6.32,2.72a2.29,2.29,0,0,1-.25-1,1.67,1.67,0,0,1,.53-1.38,2.83,2.83,0,0,1,1.34-.46v3.67a3.83,3.83,0,0,1-.77-.17A1.57,1.57,0,0,1,198.77,43.61Z" transform="translate(0 0)"/><path class="cls-1" d="M205.19,34.6a2.34,2.34,0,0,1-.54,1.63,2.11,2.11,0,0,1-1.61.59h-4.31V38h-1.32V36.82H195.3V35.19h2.11V33.35h1.32v1.84h4a1.34,1.34,0,0,0,.79-.19.79.79,0,0,0,.27-.7,2.24,2.24,0,0,0-.07-.51,2,2,0,0,0-.18-.44H205a2.57,2.57,0,0,1,.18.61A3.72,3.72,0,0,1,205.19,34.6Z" transform="translate(0 0)"/><path class="cls-1" d="M205.09,27a2.32,2.32,0,0,0-.57-1.23,1.33,1.33,0,0,0-1.13-.46h-3.63a2.82,2.82,0,0,0-1,.14,2.12,2.12,0,0,0-1.17,1.13,3.24,3.24,0,0,0-.28.81,8.34,8.34,0,0,0-.07.85,8.49,8.49,0,0,0,.18,1.69,3,3,0,0,0,.46,1.21h1.48a2.92,2.92,0,0,1-.56-1.1,4.14,4.14,0,0,1-.22-1.31,2.17,2.17,0,0,1,.36-1.37,1.4,1.4,0,0,1,1.2-.5h.7c-.07.11-.14.25-.21.39a6.39,6.39,0,0,0-.25.81c0,.32-.07.67-.07,1.06a3.82,3.82,0,0,0,.25,1.49,2.76,2.76,0,0,0,.81.95,2.91,2.91,0,0,0,1.41.32,2.36,2.36,0,0,0,1.17-.29,2.08,2.08,0,0,0,.78-.7,2.82,2.82,0,0,0,.35-1,3.81,3.81,0,0,0,.14-1.13A13,13,0,0,0,205.09,27Zm-1.24,2.41a1.3,1.3,0,0,1-.42.63,1,1,0,0,1-.71.25,1,1,0,0,1-.91-.43,2.21,2.21,0,0,1-.32-1.3,4.88,4.88,0,0,1,.35-1.7h1.45a.51.51,0,0,1,.56.43,5.23,5.23,0,0,1,.15,1.3A3.06,3.06,0,0,1,203.85,29.39Z" transform="translate(0 0)"/><path class="cls-2" d="M17.41,20.25H15.68c-.21,0-.25,0-.21-.24.09-.37.18-.73.28-1.1s.18-.76.28-1.14.19-.76.28-1.14a3.43,3.43,0,0,0,.11-.46.22.22,0,0,0-.09-.17,1.92,1.92,0,0,1-.8-1,2,2,0,0,1,0-1.33,2,2,0,0,1,2.35-1.28,2,2,0,0,1,.67,3.6.23.23,0,0,0-.1.32c.13.48.24,1,.36,1.47s.2.82.31,1.23.17.67.24,1,0,.25-.2.25Z" transform="translate(0 0)"/><circle cx="65.86" cy="27.57" r="2.35"/></svg>
     1<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 205.23 63.06"><defs><style>.cls-1{fill:#f9917a;}.cls-2{fill:#fff;}</style></defs><path d="M47,55.52c-3.45,0-6-1-7.69-2.92s-2.52-4.74-2.52-8.35q0-5.76,2.61-8.45c1.73-1.8,4.24-2.69,7.52-2.69a11.72,11.72,0,0,1,5.8,1.29,7.89,7.89,0,0,1,3.39,3.79,15.08,15.08,0,0,1,1.1,6.06q0,5.39-2.65,8.32T47,55.52Zm0-3.77a5.56,5.56,0,0,0,3.43-1,5.26,5.26,0,0,0,1.84-2.64,12,12,0,0,0,.57-3.9,12.16,12.16,0,0,0-.59-4.11,4.76,4.76,0,0,0-1.86-2.48A6.16,6.16,0,0,0,47,36.84a5.77,5.77,0,0,0-3.39.89,4.77,4.77,0,0,0-1.82,2.54,12.58,12.58,0,0,0-.55,4,9.92,9.92,0,0,0,1.31,5.51Q43.84,51.76,47,51.75Z" transform="translate(0 0)"/><path d="M63.53,55.56a5.56,5.56,0,0,1-.34,2.08A2.17,2.17,0,0,1,62,58.86a5.86,5.86,0,0,1-2.38.39v3.81a12.23,12.23,0,0,0,4.47-.74A5.75,5.75,0,0,0,67,60a8.14,8.14,0,0,0,1-4.31v-22H63.53Z" transform="translate(0 0)"/><path d="M83.49,55.52c-3.45,0-6-1-7.69-2.92s-2.52-4.74-2.52-8.35c0-3.84.86-6.66,2.6-8.45s4.25-2.69,7.52-2.69a11.73,11.73,0,0,1,5.81,1.29,7.87,7.87,0,0,1,3.38,3.79,14.91,14.91,0,0,1,1.11,6.06c0,3.59-.89,6.36-2.65,8.32S86.76,55.52,83.49,55.52Zm0-3.77a5.6,5.6,0,0,0,3.44-1,5.32,5.32,0,0,0,1.84-2.64,12.22,12.22,0,0,0,.57-3.9,12.41,12.41,0,0,0-.59-4.11,4.78,4.78,0,0,0-1.87-2.48,6.12,6.12,0,0,0-3.39-.82,5.71,5.71,0,0,0-3.38.89,4.84,4.84,0,0,0-1.83,2.54,12.88,12.88,0,0,0-.55,4A9.91,9.91,0,0,0,79,49.76Q80.31,51.76,83.44,51.75Z" transform="translate(0 0)"/><path d="M112.43,26.63h-5l-11,28.25h4.66l2.79-7.67h11.54l2.79,7.67h4.91ZM105.26,43.4l4.38-12.14,4.41,12.14Z" transform="translate(0 0)"/><path d="M136.4,55.52a12.15,12.15,0,0,1-5-1,7.12,7.12,0,0,1-3.24-2.86A9.13,9.13,0,0,1,127,47V33.62h4.44V46.33a5.73,5.73,0,0,0,1.21,4,6.1,6.1,0,0,0,7.5,0,5.73,5.73,0,0,0,1.21-4V33.62h4.28V47c0,2.83-.82,5-2.44,6.4A9.89,9.89,0,0,1,136.4,55.52Z" transform="translate(0 0)"/><path d="M159.49,55.43a6.47,6.47,0,0,1-4.55-1.52,5.76,5.76,0,0,1-1.68-4.49V37.3h-3.43V33.62h3.43V27.68h4.58v5.94H163V37.3h-5.17V48.53a3.75,3.75,0,0,0,.53,2.22,2.25,2.25,0,0,0,2,.74,5.48,5.48,0,0,0,1.44-.19,5,5,0,0,0,1.23-.48v3.94a7.55,7.55,0,0,1-1.72.5A9.66,9.66,0,0,1,159.49,55.43Z" transform="translate(0 0)"/><path d="M187,41.71V54.88h-4.45V42.27a5.72,5.72,0,0,0-1.24-4A4.59,4.59,0,0,0,177.64,37a9.17,9.17,0,0,0-2.58.35,15,15,0,0,0-2.44,1l0,16.53h-4.41V24.62h4.44V34.93a16.06,16.06,0,0,1,2.37-1.1,12,12,0,0,1,3.92-.67,10,10,0,0,1,4.27.85,6.25,6.25,0,0,1,2.75,2.75A10.4,10.4,0,0,1,187,41.71Z" transform="translate(0 0)"/><path d="M29.38,23.36q-1.21-.32-2.61-.57l0-.16v0c-.12-.69-.43-1.83-1-3.73-.83-2.92-2-6.93-3-11.71a3.36,3.36,0,0,1,.43-2.77c1.23-1.81,4.32-2.31,5.46-2.5a3.41,3.41,0,0,1,.4-.07c.64-.14.72-.57.72-.76A.77.77,0,0,0,29.12.3h-.07l0,0c-3.27-.29-6.36-.55-9,.26-3,.9-5,3.06-6.41,6.81L8,22.67l-.1.15c-.85.16-1.66.35-2.42.54C1.83,24.31,0,25.62,0,27.21c0,1.32,1.26,2.45,3.76,3.35V54.87H8.28V33.37l9,13,9.43-13V54.87h4.66V30.42c2.27-.87,3.41-2,3.41-3.21C34.82,25.62,33,24.31,29.38,23.36ZM17.53,39.73l-5.11-7.54c1.59.13,3.28.2,5,.2s3.67-.08,5.39-.23Z" transform="translate(0 0)"/><path class="cls-2" d="M17.41,20.25H15.68c-.21,0-.25,0-.21-.24.09-.37.18-.73.28-1.1s.18-.76.28-1.14.19-.76.28-1.14a3.43,3.43,0,0,0,.11-.46.22.22,0,0,0-.09-.17,1.92,1.92,0,0,1-.8-1,2,2,0,0,1,0-1.33,2,2,0,0,1,2.35-1.28,2,2,0,0,1,.67,3.6.23.23,0,0,0-.1.32c.13.48.24,1,.36,1.47s.2.82.31,1.23.17.67.24,1,0,.25-.2.25Z" transform="translate(0 0)"/><circle cx="65.86" cy="27.57" r="2.35"/></svg>
  • mojoauth/trunk/admin/index.php

    r2593508 r2655014  
    128128        {
    129129            $apikey = mojoAuthPlugin::data_validation('mojoauth_apikey', $_POST);
    130             require_once(MOJOAUTH_ROOT_DIR."mojoAuthWPClient.php");
     130            require_once(MOJOAUTH_ROOT_DIR . "mojoAuthWPClient.php");
    131131            $client = new mojoAuthWPClient($apikey);
    132             wp_die(json_encode($client->getPublicKey()));
     132            wp_die(json_encode($client->getPublicKey()));
    133133        }
    134134       
  • mojoauth/trunk/admin/views/settings.php

    r2593508 r2655014  
    2323                </label>
    2424                <input type="text" id="mojoauth_apikey" name="mojoauth_option[apikey]" value="<?php echo isset($mojoauth_option['apikey'])?esc_attr($mojoauth_option['apikey']):"";?>" placeholder="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx">
    25                 <div class="mojoauth_verification button" disabled><?php _e('Get Public Certificate','mojoauth');?></div>
     25                <div class="mojoauth_verification button" disabled><?php _e('Get Public Certificate','mojoauth');?></div>
     26                <div class="mojoauth_help_text"><?php _e('<a href="https://mojoauth.com/signin" target="_blank">Log in to MojoAuth</a> and get your API key under the <a href="https://mojoauth.com/dashboard/overview" target="_blank">overview</a> section.','mojoauth');?></div>
    2627                <div class="mojoauth_verification_message" style="display:none;"></div>
    2728            </div>
     
    4041-----END PUBLIC KEY-----
    4142"><?php echo isset($mojoauth_option['public_key'])?esc_attr($mojoauth_option['public_key']):"";?></textarea>
     43<div class="mojoauth_help_text"><?php _e('Get your public certificate by clicking on the Get Public Certificate button. This certificate will be used to verify the token.','mojoauth');?></div>
     44            </div>
     45            <div class="mojoauth_field">
     46                <label for="mojoauth_language">
     47                <?php _e('Language:','mojoauth');?>
     48                </label>
     49                <select id="mojoauth_language" name="mojoauth_option[language]">
     50                    <?php
     51                    $mojoAuthLanguages = array('en'=>'English',
     52                    'it'=>'Italian',
     53                    'de'=>'German',
     54                    'fr'=>'French',
     55                    'es'=>'Spanish');
     56                        foreach($mojoAuthLanguages as $lan=>$language){
     57                            $selectedLanguage = isset($mojoauth_option['language']) && !empty($mojoauth_option['language'])?trim($mojoauth_option['language']):'en';
     58                            ?>
     59                            <option value="<?php _e($lan,'mojoauth');?>"
     60                            <?php
     61                            if($selectedLanguage==$lan){
     62                                ?> selected="selected"<?php
     63                            }
     64                            ?>
     65                            ><?php _e($language,'mojoauth');?></option>
     66                            <?php
     67                        }                   
     68                    ?>
     69                   
     70                </select>
     71                <div class="mojoauth_help_text"><?php _e('Localize your website according to your country or region. Check the <a href="https://mojoauth.com/docs/configurations/localization/" target="_blank">supported languages</a> page.','mojoauth');?></div>
    4272            </div>
    4373            <hr>
  • mojoauth/trunk/frontend/assets/js/loginpage.js

    r2593508 r2655014  
    1616
    1717
    18         const mojoauth = new MojoAuth(mojoauthajax.apikey);
     18        const mojoauth = new MojoAuth(mojoauthajax.apikey,{
     19            language: mojoauthajax.language,
     20            redirect_url: mojoauthajax.redirect,
     21        });
    1922        mojoauth.signInWithMagicLink().then(response => {
    2023            if (response.authenticated == true) {
     
    2528                    };
    2629                    // We can also pass the url value separately from ajaxurl for front end AJAX implementations
    27                     jQuery.post(mojoauthajax.ajax_url, data, function (wpresponse) {
    28                         window.location.href = mojoauthajax.redirect
    29                     });
     30                    setInterval(function(){
     31                        jQuery.post(mojoauthajax.ajax_url, data, function (wpresponse) {
     32                            window.location.href = mojoauthajax.redirect
     33                        });
     34                    },2000);
    3035                }
    3136        });
  • mojoauth/trunk/frontend/pages/auth.php

    r2593508 r2655014  
    2121            add_action('wp_ajax_mojoauth_login', array($this,'mojoauth_login'));
    2222            add_action('wp_ajax_nopriv_mojoauth_login', array($this,'mojoauth_login'));
     23            add_action('init',array($this,'mojoauth_StateIdHandler'));
    2324        }
    2425        /**
     
    3233            $mojoauth_option = get_option('mojoauth_option');
    3334            $apikey = isset($mojoauth_option["apikey"]) && !empty($mojoauth_option["apikey"])?trim($mojoauth_option["apikey"]):"";
     35            $language = isset($mojoauth_option["language"]) && !empty($mojoauth_option["language"])?trim($mojoauth_option["language"]):"en";
    3436            wp_enqueue_script('mojoauth-js', 'https://cdn.mojoauth.com/js/mojoauth.min.js', false, MOJOAUTH_PLUGIN_VERSION);
    3537            wp_enqueue_script('mojoauthajax-script', MOJOAUTH_ROOT_URL . 'frontend/assets/js/loginpage.js', array('mojoauth-js'), MOJOAUTH_PLUGIN_VERSION);
    36             wp_localize_script('mojoauthajax-script', 'mojoauthajax', array('ajax_url' => admin_url('admin-ajax.php'), 'apikey' => $apikey, 'redirect' => home_url()));
     38            wp_localize_script('mojoauthajax-script', 'mojoauthajax', array('ajax_url' => admin_url('admin-ajax.php'),
     39            'apikey' => $apikey,
     40            'language' => $language,
     41            'redirect' => home_url()));
    3742        }
     43        /**
     44         * Handler for state ID
     45         */
     46        public function mojoauth_StateIdHandler(){
     47            $state_id = mojoAuthPlugin::data_validation('state_id', $_GET);
     48            if (!empty($state_id)) {
     49                //call API
     50                $mojoauth_option = get_option('mojoauth_option');
     51                $apikey = isset($mojoauth_option["apikey"])?trim($mojoauth_option["apikey"]):"";
     52                if (!empty($apikey)) {
     53                    require_once(MOJOAUTH_ROOT_DIR."mojoAuthWPClient.php");
     54                    $client = new mojoAuthWPClient($apikey);
     55
     56                    $mojoAutoUserResponse = $client->checkLoginStatus($state_id);
     57                    $mojoAutoUser = isset($mojoAutoUserResponse['response'])?json_decode($mojoAutoUserResponse['response']):false;
     58                    if (isset($mojoAutoUser->user) && isset($mojoAutoUser->user->identifier) && !empty($mojoAutoUser->user->identifier)) {
     59                        $this->allow_login($mojoAutoUser->user->identifier);
     60                    }
     61                }
     62            }
     63        }
    3864        /**
    3965         * Login handler
     
    5278
    5379                $mojoAutoUser = $client->getUserProfileData($token, $publicKey);
     80               
    5481                if ($mojoAutoUser->identifier && $email) {
    55                     $user = get_user_by('email', $email);
    56                    
    57                     if (!$user) {
    58                         $username = $this->get_username($email, 0);
    59                         //create user in wp database
    60                         $result = wp_create_user($username, $email, $email);
    61                         if (is_wp_error($result)) {
    62                             $error = $result->get_error_message();
    63                         //handle error here
    64                         } else {
    65                             $user = get_user_by('id', $result);
    66                         }
    67                     }
    68                     //login user
    69                     wp_clear_auth_cookie();
    70                     wp_set_auth_cookie($user->ID, true);
    71                     wp_set_current_user($user->ID);
    72                     do_action('wp_login', $user->data->user_login, $user);
     82                    $this->allow_login($email);
    7383                }
    7484            }
    7585            wp_die();
    7686        }
     87        /**
     88         * Allow Login by email
     89         */
     90        private function allow_login($email){
     91            $user = get_user_by('email', $email);
     92            if (!$user) {
     93                $username = $this->get_username($email, 0);
     94                //create user in wp database
     95                $result = wp_create_user($username, $email, $email);
     96                if (is_wp_error($result)) {
     97                    $error = $result->get_error_message();
     98                //handle error here
     99                } else {
     100                    $user = get_user_by('id', $result);
     101                }
     102            }
     103            //login user
     104            wp_clear_auth_cookie();
     105            wp_set_auth_cookie($user->ID, true);
     106            wp_set_current_user($user->ID);
     107            do_action('wp_login', $user->user_login, $user);
     108        }
    77109        /**
    78110         * get unique username
  • mojoauth/trunk/mojoauth.php

    r2642260 r2655014  
    55 * Plugin URI: https://github.com/MojoAuth/mojoauth-wordpress
    66 * Description: MojoAuth provides a secure and delightful experience to your customer with passwordless. Here, you'll find comprehensive guides and documentation to help you to start working with MojoAuth APIs.
    7  * Version: 1.1
     7 * Version: 1.2
    88 * Author: Mojoauth Team
    99 * Author URI: https://mojoauth.com
     
    1616define('MOJOAUTH_ROOT_DIR', plugin_dir_path(__FILE__));
    1717define('MOJOAUTH_ROOT_URL', plugin_dir_url(__FILE__));
    18 define('MOJOAUTH_PLUGIN_VERSION', '1.1');
     18define('MOJOAUTH_PLUGIN_VERSION', '1.2');
    1919define('MOJOAUTH_ROOT_SETTING_LINK', plugin_basename(__FILE__));
    2020
     
    6161         */
    6262        public static function data_validation($key, $post){
    63             return isset($post[$key]) && !empty($post[$key]) ? sanitize_text_field(esc_html(wp_kses(trim($post[$key])))) : false;
     63            return isset($post[$key]) && !empty($post[$key]) ? sanitize_text_field(esc_html(trim($post[$key]))) : false;
    6464        }
    6565        /**
     
    6767         */
    6868        public static function email_validation($key, $post){
    69             return isset($post[$key]) && !empty($post[$key]) ? sanitize_email(esc_html(wp_kses(trim($post[$key])))) : false;
     69            return isset($post[$key]) && !empty($post[$key]) ? sanitize_email(esc_html(trim($post[$key]))) : false;
    7070        }
    7171       
  • mojoauth/trunk/readme.txt

    r2642260 r2655014  
    1 
    21=== MojoAuth Passwordless Authentication ===
    32Contributors: MojoAuth
     
    65Requires at least: 3.4
    76Tested up to: 5.8
    8 Stable tag: 1.1
     7Stable tag: 1.2
    98Requires PHP: 5.6
    109License: GPLv2 or later
     
    7271== Changelog ==
    7372
     73= 1.2 =
     74* Localization with 5 languages
     75* Handle magic link redirection
     76
    7477= 1.1 =
    7578* Messaging update
     
    8083== Upgrade Notice ==
    8184
     85= 1.2 =
     86* Localization with 5 languages
     87* Handle magic link redirection
     88
    8289= 1.1 =
    8390* Messaging update
  • mojoauth/trunk/sdk/mojoAuthAPI.php

    r2593508 r2655014  
    11<?php
    22require_once(__DIR__."/lib/vendor/autoload.php");
    3 require_once(__DIR__."/chilkat_9_5_0.php");
    43use Lcobucci\JWT\Configuration;
    54use Lcobucci\JWT\UnencryptedToken;
     
    105104    public function getPublicKey()
    106105    {
    107         $jwks = $this->JWKS();
    108         $jwksResponse = isset($jwks["response"])?json_decode($jwks["response"]):false;
    109         if(!$jwksResponse->description){
    110             if(!extension_loaded('chilkat_9_5_0')){
    111                 return array("status_code"=>500,"message"=>'chilkat_9_5_0 is not enabled, enable chilkat_9_5_0 to get response from https://www.chilkatsoft.com/installPhpExtension.asp or use Public Certificate manually.');
    112                 exit;
    113             }
    114             $pubKey = new CkPublicKey();
    115             $success = $pubKey->LoadFromString(json_encode($jwksResponse->keys[0]));
    116             if ($success != true) {
    117                 return array("status_code"=>500,"message"=>$pubKey->lastErrorText());
    118                 exit;
    119             }
    120             return array("status_code"=>$jwks["status_code"],"data"=>$pubKey->getPem(false));
    121         }
    122         return array("status_code"=>($jwksResponse->code),"message"=>($jwksResponse->description));
     106        if(!extension_loaded('chilkat_9_5_0')){
     107            return array("status_code"=>500,"message"=>'chilkat_9_5_0 is not enabled, enable chilkat_9_5_0 to get response from https://www.chilkatsoft.com/installPhpExtension.asp or use Public Certificate manually.');
     108            exit;
     109        }else{
     110            $jwks = $this->JWKS();
     111            $jwksResponse = isset($jwks["response"])?json_decode($jwks["response"]):false;
     112            if(!$jwksResponse->description){
     113                require_once(__DIR__."/chilkat_9_5_0.php");
     114                $pubKey = new CkPublicKey();
     115                $success = $pubKey->LoadFromString(json_encode($jwksResponse->keys[0]));
     116                if ($success != true) {
     117                    return array("status_code"=>500,"message"=>$pubKey->lastErrorText());
     118                    exit;
     119                }
     120                return array("status_code"=>$jwks["status_code"],"data"=>$pubKey->getPem(false));
     121            }
     122            return array("status_code"=>($jwksResponse->code),"message"=>($jwksResponse->description));
     123        }
    123124    }
    124125    /**
     
    127128    public function getUserProfileData($access_token, $publicKey)
    128129    {
    129         return JWT::decode($access_token, $publicKey, array('RS256'));
     130        return JWT::decode($access_token, $publicKey, array('RS256'));
    130131    }
    131132    /**
Note: See TracChangeset for help on using the changeset viewer.