Allow.authenticated #373
Unanswered
danielchernilov
asked this question in
Q&A
Replies: 1 comment
-
Checkout the auth tutorial step: On the backend, you can tell remult how to figure out the current user based on the request: // src/server/api.ts
//...
export const api = remultExpress({
//...
getUser: req => req.session!["user"]
}) In the frontend, once you identify the user, simply set the const signIn = async (e: FormEvent) => {
e.preventDefault()
const result = await fetch("/api/signIn", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ username })
})
if (result.ok) {
remult.user = await result.json() // --> set the user in the frontend
setSignedIn(true)
setUsername("")
} else {
alert(await result.json())
}
} This will also set the roles that'll be used for allow methods and in the call to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
How can one control the state of Allow.authenticated as demonstrated in the following video at 6:31? Are there specific methods within the Remult library that enable users to manage the authentication status using Allow.authenticated?
Beta Was this translation helpful? Give feedback.
All reactions