Plugin to use discourse as primitive authentication provider and to export selected user data
This plugin adds a couple of new API methods that can be used to interact with discourse as central user database. All of them require an admin user API token.
All API methods return a boolean flag that indicates the success of the method call:
{ success: Boolean, error: String, ... }
The optional field error
explains the failure in case success == false
.
POST /admin/course/auth.json
- user
- password
None
GET /admin/course/dump.json
Dumps the userdata together with customized user-fields. The flag staff
can
be used to indicate whether only students or only staff should be dumped.
Right now it is not possible to dump both at the same time.
- export: [String] (Exported members and fields of
USER
, e.g.,["username","info1"]
. Defaults toSiteSetting.export_user_members.split('|')
.) - staff: Boolean (Select by
user.staff
. Defaults tofalse
.) - group: String (Select members of named group. Defaults to
nil
.) - confirmed: [String] (Select by checked confirmation user fields. Defaults to
nil
.)
{ users: [USER] }
Here the information contained in the object USER can be configured in the admin area of discourse under "Settings/Plugins".
You can explore the available fields and methods on User
in the discourse implementation user.rb.
PUT /admin/course/user_field.json
- userid
- userfield
- value
userfield
is either the name of the userfield to set a value or a custom identifier, configured under "Settings/Plugins".
None
PUT /admin/course/user_fields.json
- { data: [USER_FIELD_UPDATE] }
where
USER_FIELD_UPDATE = {
userid: Number,
userfield: String,
value: String
}
It is important that the following headers are set in your request:
Content-Type: application/json
Accept: application/json
For instance when using curl
:
url -X PUT -H 'Accept: application/json' -H 'Content-type: application/json' -d '{ "data" : [{ "userid": 1, ...}] }' '<URL>/admin/course/user_fields.json?api_key=<API_KEY>&api_username=<USERNAME>'
For possible values of USER_FIELD_UPDATE
properties see "Set User Field". Updating
None
GET /admin/course/add_people_to_default_lecture_group.json
For all non-staff users not belonging to any active lecture, add them to the default lecture group.
None
List of usernames newly added to default lecture group
GET /admin/course/synchronize_all_user_fields_and_groups.json
For all non-staff users, set their membership in active lecture groups according to the corresponding user fields.
None
List of usernames whose user groups are modified by the command