Discussion Forum context object configuration
- 1.1 Introduction
- 2 Background
- 3 Problem Statement
- 3.1 Solution
- 3.2 Master Token
Introduction
https://project-sunbird.atlassian.net/browse/SB-22678
This wiki is for adding the logged in user identifier also some extra info data into sbCategory collection (The one that we are storing the context objects).
Background
As of now there is no check for removing the context from collection, anyone can remove.
Now we are adding a check(owner check) that enable the user to remove their own context form collection.
Problem Statement
How can we get the logged in user id from (Portal/Igot or any application).
How to map those identifier with context.
Where/How to add that owner check.
Solution
As per the previous discussions, I am creating the solution.
Step1: Pass authentication token from UI upto NodeBB plugins
From Portal or any application, They have to pass authentication token for all api calls in headers so that this headers will go to middleware and then it will go to Nodebb plugins.
Step2: Decode the token and take the identifier
after getting the authentication token, decode the token and take the Identifier
Note: Authentication token must contain the identifier.
Step3:
a. While creating the context added extra information like, we are storing date like below
{
sbType: 'course',
sbIdentifier: do_21307805474221260815237,
cid: [2],
data: {
createdBy: ${userIdentifier},
createdAt: DATE,
updatedBy: ${userIdentifier},
updatedAt: DATE
}
}
Key | type | value |
---|---|---|
sbType | string | course/batch/group |
sbIdentifier | string | do_21307805474221260815237/01307806402750054416/84cb1ca0-3707-497c-a385-50cb5ac12390 |
cid | array | [2,5,8….] |
data | object | {….} |
data.createdBy | string |
|
data.createdAt | Date | March 22nd 2021 |
data.updatedBy | string |
|
data.updatedAt | Date | March 23rd 2021 |
b. For removing the forum, we have to do owner check, below flow chat will show that
Master Token
As we disused previously, we have to use master token along with uid instead of user token.