chyrp-lite sso #195
Replies: 6 comments 1 reply
-
Within the Chyrp Lite environment it's quite simple to check if the user is logged in; the function would look like this:
If you want to check the login status outside the Chyrp Lite environment, you should inspect |
Beta Was this translation helpful? Give feedback.
-
Unfortunately I only have enough free time to work on core Chyrp Lite development. If other people also want this feature, perhaps they will see the discussion and volunteer to help. In the meantime, there were a few errors in your code that I have corrected:
|
Beta Was this translation helpful? Give feedback.
-
I feel guilty to ask for help again. I cudgeled my brain but still couldn't work out. Attached is my finished file I almost finish my customization with Chyrp Lite (https://en.idea.angelcorp.net/blog/) but got stuck with SSO. To be honest with you, I'm not an IT person. My major is accounting. Probably I'm not smart enough. Could you please help? |
Beta Was this translation helpful? Give feedback.
-
If you prefer to read right here, following is my finished file "qa-external-users.php" and attached is the original file qa-external-users-original.zip /*
*/ /*
*/ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser /**
/**
/**
/**
/**
/**
/**
/**
/**
/**
|
Beta Was this translation helpful? Give feedback.
-
Is there a way to slightly modify code in Chyrp Lite in order to integrate with Question2Answer, like explained in this article regarding integrating Ajax-Chat with Q2A (https://digitizor.com/integrate-ajaxchat-question2answer-q2a/)? Thank you. |
Beta Was this translation helpful? Give feedback.
-
Chyrp Lite can be significantly modified and extended using modules. But you need to find a software integrator to help you implement your customizations; this is not a service I can provide for free in my spare time. |
Beta Was this translation helpful? Give feedback.
-
It could be a nice feature if chyrp-lite can be integrated into other programs. Currently I installed Question2Answer (also an open source program) in root directory and installed chyrp-lite under "blog" directory. Question2Answer is built with single sign-on. Somehow I couldn't make the following function work, could you please help with the code?
function qa_get_logged_in_user()
{
if (isset($_COOKIE['sessionid'])) {
$result = qa_db_read_one_assoc(qa_db_query_sub(
'SELECT userid, username, email, admin_flag FROM users WHERE userid=(SELECT userid FROM sessions WHERE sessionid=#)',
$_COOKIE['sessionid']
));
if (is_array($result)) {
return array(
'userid' => $result['user_id'],
'publicusername' => $result['login'],
'email' => $result['email'],
'level' => ($userid == '1') ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
);
}
}
return null;
}
Following is the full instruction regarding this function:
*
qa_get_logged_in_user()
You should check (using $_COOKIE, $_SESSION or whatever is appropriate) whether a user is
currently logged in. If not, return null. If so, return an array with the following elements:
QA_USER_LEVEL_BASIC, QA_USER_LEVEL_EDITOR, QA_USER_LEVEL_ADMIN, QA_USER_LEVEL_SUPER
To indicate that the user is blocked you can also add an element 'blocked' with the value true.
Blocked users are not allowed to perform any write actions such as voting or posting.
The result of this function will be passed to your other function qa_get_logged_in_user_html()
so you may add any other elements to the returned array if they will be useful to you.
Call qa_db_connection() to get the connection to the Q2A database. If your database is shared with
Q2A, you can also use the various qa_db_* functions to run queries.
In order to access the admin interface of your Q2A site, ensure that the array element 'level'
contains QA_USER_LEVEL_ADMIN or QA_USER_LEVEL_SUPER when you are logged in.
*/
function qa_get_logged_in_user()
{
// Until you edit this function, nobody is ever logged in
return null;
/*
Example 1 - suitable if:
*/
/*
Example 2 - suitable if:
*/
}
Beta Was this translation helpful? Give feedback.
All reactions