1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

User Signin 1.2

User login and registration

  1. robin007

    robin007 Well-Known Member

    2018-03-11 18_35_37-New message from Hotaru CMS - robinblogspot@gmail.com - Gmail.png
    When i send private message to a user they got email notification with reply link. When they click the link without login they got "page not found" error.

    it could be redirect to login page
     
    Last edited: Mar 11, 2018
  2. valMETNG

    valMETNG Administrator Staff Member Admin

    There really should be a global function in Hotaru that checks if a login is required before accessing a plugin page. This is a bit of a quick kludge but please add to Hotaru.php after line 3121 (right before the last squiggly bracket):
    Code:
    public function checkLoggedIn($check_pages = array())
    {
        if (!$check_pages || !isset($this->pageName) || !$this->pageName || !in_array($this->pageName, $check_pages)) { return false; }
    
        if (!$this->currentUser->loggedIn)
        {
            // determine where to return the user to after logging in:
            if (!$this->cage->get->keyExists('return'))
            {
                $host = $this->cage->server->sanitizeTags('HTTP_HOST');
                $uri = $this->cage->server->sanitizeTags('REQUEST_URI');
                $return = 'http://' . $host . $uri;
                $return = urlencode(htmlentities($return, ENT_QUOTES,'UTF-8'));
            } else // use existing return parameter
            { $return = urlencode($this->cage->get->testUri('return')); }
    
            header("Location: " . BASEURL . 'index.php?page=login&return=' . $return);
        }
    
        return true;
    }
    Now you should be able to add the following to the beginning of the function theme_index_top in any plugin which requires the user be logged in before continuing (in your case, add after line 50 of /plugins/messaging/messaging.php), which will check the specified page names and redirect to a login page:
    Code:
    if (!$h->checkLoggedIn(array('inbox', 'outbox', 'compose', 'show_message'))) { return false; }
    Please let us know if that works for you.
     
  3. robin007

    robin007 Well-Known Member

    perfect:cool:
     
  4. robin007

    robin007 Well-Known Member

    Give options to login with username or Email address. If it is secure
     
    Last edited: Mar 15, 2018
  5. robin007

    robin007 Well-Known Member

    [DOM] Found 15 elements with non-unique id
    2018-06-09 17_37_03-.png
     
  6. valMETNG

    valMETNG Administrator Staff Member Admin

    Which page?
     
  7. robin007

    robin007 Well-Known Member

    My home page
    Chrome inspect
     
  8. valMETNG

    valMETNG Administrator Staff Member Admin

    Looking at your source HTML, you've got a few problems in your customized vote template with duplicate form and input ids and names which, generally speaking, are a no-no. You'll probably want to add the post_id to the end of your vote template ids and names so they're unique, but that will also mean that you'll need to change the way function login (line 258) of user_signin.php works (e.g., checking the names of POST data and then assigning the appropriate name).

    Something like this for templates:
    Code:
    <form id="signin<?php echo $h->post->id; ?>" action="//your-website/index.php" method="post">
    <input id="username<?php echo $h->post->id; ?>" class="form-control" placeholder="Username" name="username<?php echo $h->post->id; ?>" value="" title="username" tabindex="1" type="text" autofocus="">
    <input id="password<?php echo $h->post->id; ?>" class="form-control" name="password<?php echo $h->post->id; ?>" placeholder="password" value="" title="password" tabindex="2" type="password">
    Changes for the function login will be more complicated. I'm not sure but something like this to replace lines 260-261 might work:
    Code:
    $username_check = "";
    $password_check = "";
    foreach ($h->cage->post as $signin_field)
    {
        if (!$username_check && substr($signin_field, 0, 8) == 'username' && $h->cage->post->testUsername($signin_field)) { $username_check = $h->cage->post->testUsername($signin_field); }
        if (!$password_check && substr($signin_field, 0, 8) == 'password' && $h->cage->post->testPassword($signin_field)) { $password_check = $h->cage->post->testPassword($signin_field); }
    }
     
    robin007 likes this.

Share This Page