The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Login via JSON Web Token
#1
Hello all,

Hoping you all will be able to help with this.

The website I am developing is using Userspice. The website; however, is a part of a larger organization that requires logins to be handled by their central server via a JSON Web Token. After the login is successful, it passes the user's email, username, and a few other JSON fields back to our Userspice website. The email and username that is passed back from the central server will need to be verified with our Userspice user database, and if there is a match, a session will be created.

I was wondering how to go about this? I begun messing with the User.php file, but had issues editing the loginEmail function. I attempted to remove the password verification to just do it solely off of the email passed back to the website and it did not work:

<pre>
Code:
public function logincentral ($email = null){

        if (!$email && $this->exists()) {
            Session::put($this->_sessionName, $this->data()->id);
        } else {
            $user = $this->find($email);

            if ($user) {
                    Session::put($this->_sessionName, $this->data()->id);

                    $date = date("Y-m-d H:i:s");
                    $this->_db->query("UPDATE users SET last_login = ?, logins = logins + 1 WHERE id = ?",[$date,$this->data()->id]);
                    $this->_db->query("UPDATE users SET last_confirm = ? WHERE id = ?",[$date,$this->data()->id]);
                    $ip = ipCheck();
                    $q = $this->_db->query("SELECT id FROM us_ip_list WHERE ip = ?",array($ip));
                    $c = $q->count();
                    if($c < 1){
                        $this->_db->insert('us_ip_list', array(
                            'user_id' => $this->data()->id,
                            'ip' => $ip,
                        ));
                    }else{
                        $f = $q->first();
                        $this->_db->update('us_ip_list',$f->id, array(
                            'user_id' => $this->data()->id,
                            'ip' => $ip,
                        ));
                    }
                    return true;
            }
        }
        return false;
    }
</pre>


The login page is as follows, after getting the JSON fields:
<pre>
Code:
$user = new User();
$login = $user->loginULS($controller_email);
</pre>


I am not getting any data back in the $login variable. Any help would be greatly appreciated. Thank you!
  Reply


Messages In This Thread
Login via JSON Web Token - by petey - 12-30-2017, 05:05 AM
RE: Login via JSON Web Token - by ivinsons - 12-16-2018, 09:37 PM
Login via JSON Web Token - by Brandin - 12-30-2017, 01:21 PM
Login via JSON Web Token - by petey - 12-30-2017, 02:44 PM
Login via JSON Web Token - by Brandin - 12-30-2017, 04:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)