forked from blitz-js/blitz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authenticate does not work with roles (blitz-js#4225)
* fix logic to test the role * add tests * pnpm lock * Create afraid-ligers-build.md --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
aec1bb0
commit cee2dec
Showing
5 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@blitzjs/auth": patch | ||
"blitz": patch | ||
--- | ||
|
||
Fix bug that did not allow `Page.authenicate = {role: "" }` to correctly work |
37 changes: 37 additions & 0 deletions
37
integration-tests/auth-with-rpc/src/pages/page-dot-authenticate-role-working.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {useMutation, useQuery} from "@blitzjs/rpc" | ||
import {BlitzPage} from "@blitzjs/next" | ||
import logout from "../mutations/logout" | ||
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic" | ||
import {Suspense} from "react" | ||
|
||
function Content() { | ||
const [result] = useQuery(getAuthenticatedBasic, undefined) | ||
const [logoutMutation] = useMutation(logout) | ||
return ( | ||
<div> | ||
<div id="content">{result}</div> | ||
<button | ||
id="logout" | ||
onClick={async () => { | ||
await logoutMutation() | ||
}} | ||
> | ||
logout | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
const Authenticate: BlitzPage = () => { | ||
return ( | ||
<div id="page"> | ||
<Suspense fallback={"Loading..."}> | ||
<Content /> | ||
</Suspense> | ||
</div> | ||
) | ||
} | ||
|
||
Authenticate.authenticate = {role: "new role"} | ||
|
||
export default Authenticate |
37 changes: 37 additions & 0 deletions
37
integration-tests/auth-with-rpc/src/pages/page-dot-authenticate-role.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {useMutation, useQuery} from "@blitzjs/rpc" | ||
import {BlitzPage} from "@blitzjs/next" | ||
import logout from "../mutations/logout" | ||
import getAuthenticatedBasic from "../queries/getAuthenticatedBasic" | ||
import {Suspense} from "react" | ||
|
||
function Content() { | ||
const [result] = useQuery(getAuthenticatedBasic, undefined) | ||
const [logoutMutation] = useMutation(logout) | ||
return ( | ||
<div> | ||
<div id="content">{result}</div> | ||
<button | ||
id="logout" | ||
onClick={async () => { | ||
await logoutMutation() | ||
}} | ||
> | ||
logout | ||
</button> | ||
</div> | ||
) | ||
} | ||
|
||
const Authenticate: BlitzPage = () => { | ||
return ( | ||
<div id="page"> | ||
<Suspense fallback={"Loading..."}> | ||
<Content /> | ||
</Suspense> | ||
</div> | ||
) | ||
} | ||
|
||
Authenticate.authenticate = {role: "ADMIN"} | ||
|
||
export default Authenticate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters