mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use session access_tokens
This commit is contained in:
parent
08cc97f557
commit
52f2235942
74 changed files with 413 additions and 440 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||
import { useOrg } from '@components/Contexts/OrgContext'
|
||||
import { getAPIUrl } from '@services/config/config'
|
||||
import { linkUserToUserGroup, unLinkUserToUserGroup } from '@services/usergroups/usergroups'
|
||||
|
|
@ -14,6 +15,8 @@ type ManageUsersProps = {
|
|||
|
||||
function ManageUsers(props: ManageUsersProps) {
|
||||
const org = useOrg() as any
|
||||
const session = useLHSession() as any
|
||||
const access_token = session.data.tokens.access_token;
|
||||
const { data: OrgUsers } = useSWR(
|
||||
org ? `${getAPIUrl()}orgs/${org.id}/users` : null,
|
||||
swrFetcher
|
||||
|
|
@ -31,7 +34,7 @@ function ManageUsers(props: ManageUsersProps) {
|
|||
}
|
||||
|
||||
const handleLinkUser = async (user_id: any) => {
|
||||
const res = await linkUserToUserGroup(props.usergroup_id, user_id)
|
||||
const res = await linkUserToUserGroup(props.usergroup_id, user_id,access_token)
|
||||
if (res.status === 200) {
|
||||
toast.success('User linked successfully')
|
||||
mutate(`${getAPIUrl()}usergroups/${props.usergroup_id}/users`)
|
||||
|
|
@ -41,7 +44,7 @@ function ManageUsers(props: ManageUsersProps) {
|
|||
}
|
||||
|
||||
const handleUnlinkUser = async (user_id: any) => {
|
||||
const res = await unLinkUserToUserGroup(props.usergroup_id, user_id)
|
||||
const res = await unLinkUserToUserGroup(props.usergroup_id, user_id,access_token)
|
||||
if (res.status === 200) {
|
||||
toast.success('User unlinked successfully')
|
||||
mutate(`${getAPIUrl()}usergroups/${props.usergroup_id}/users`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue