/auth
Search
⌃K
Comment on page

hasOrgRole

This function checks if a user has the role for an organizationID and roleName.

Usage

import React, { useEffect, useState } from 'react';
import { useSlashAuth } from '@slashauth/slashauth-react';
​
export const HasOrgRole = () => {
const { hasOrgRole } = useSlashAuth();
const [hasR, setHasR] = useState(false);
​
useEffect(() => {
hasOrgRole('abcd1234', 'Member').then((role) => setHasR(role));
}, [hasOrgRole]);
​
return <div>{`Has role for org? ${hasR}`}</div>;
}

Return Value

boolean

Configuration

organizationID

Unique string that represents your organization.
import React, { useEffect, useState } from 'react';
import { useSlashAuth } from '@slashauth/slashauth-react';
​
export const HasOrgRole = () => {
const { hasOrgRole } = useSlashAuth();
const [hasR, setHasR] = useState(false);
​
useEffect(() => {
hasOrgRole('abcd1234', 'Member').then((role) => setHasR(role));
}, [hasOrgRole]);
​
return <div>{`Has role for org? ${hasR}`}</div>;
}

roleName

The name of the role that you are calling.
import React, { useEffect, useState } from 'react';
import { useSlashAuth } from '@slashauth/slashauth-react';
​
export const HasOrgRole = () => {
const { hasOrgRole } = useSlashAuth();
const [hasR, setHasR] = useState(false);
​
useEffect(() => {
hasOrgRole('abcd1234', 'Member').then((role) => setHasR(role));
}, [hasOrgRole]);
​
return <div>{`Has role for org? ${hasR}`}</div>;
}
Last modified 10mo ago