Skip to content

Commit

Permalink
feat: create role unauthorized exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmagnus committed Feb 1, 2024
1 parent 53ded2f commit a2ba579
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/hooks/useAuth/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ export const AuthProvider: React.FC<IProps> = ({ children }) => {
setCreatingRole(true)
try {
const user = Authentication.getUser()

if (!user?.id) throw new Error('Unauthorized error')

const response = await http.post(`role`, {
name: name,
created_by: user?.id ? Number(user.id) : null,
created_by: Number(user.id),
})
if (response.status !== 200) {
throw new Error()
Expand Down

0 comments on commit a2ba579

Please sign in to comment.