First commit.
This commit is contained in:
25
api/src/lib/auth.js
Normal file
25
api/src/lib/auth.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Once you are ready to add authentication to your application
|
||||
* you'll build out requireAuth() with real functionality. For
|
||||
* now we just return `true` so that the calls in services
|
||||
* have something to check against, simulating a logged
|
||||
* in user that is allowed to access that service.
|
||||
*
|
||||
* See https://redwoodjs.com/docs/authentication for more info.
|
||||
*/
|
||||
export const isAuthenticated = () => {
|
||||
return true
|
||||
}
|
||||
|
||||
export const hasRole = ({ roles }) => {
|
||||
return roles !== undefined
|
||||
}
|
||||
|
||||
// This is used by the redwood directive
|
||||
// in ./api/src/directives/requireAuth
|
||||
|
||||
// Roles are passed in by the requireAuth directive if you have auth setup
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export const requireAuth = ({ roles }) => {
|
||||
return isAuthenticated()
|
||||
}
|
||||
Reference in New Issue
Block a user