Authentication
WARNING
The authentication in the template is for demonstration purposes only; there is no database connection.
Deska uses Nuxt Auth Utils to provide a collection of authentication utilities that simplify auth handling.
Usage
You need to set the respective providers in your nuxt.config.ts.
ts
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
oauth: {
// provider in lowercase (github, google, etc.)
<provider>: {
clientId: '...',
clientSecret: '...'
}
}
}
})You can find detailed documentation here
Auth Middleware
the global middleware ./app/middleware/auth.global.ts ensures that users are correctly redirected based on their authentication status and route metadata.
Public Routes (
meta.public)- If a route is marked as
public, the middleware allows access without any restrictions.
- If a route is marked as
Guest Routes (
meta.guest)- If a route is marked as
guest(e.g login page), but the user is already logged in, they are redirected to the homepage (/).
- If a route is marked as
Protected Routes (Neither
meta.publicNormeta.guest)- All routes not marked as
publicorguestrequires authentication.
- All routes not marked as
Usage
Example login page:
js
<script lang="ts" setup>
definePageMeta({
guest: true // Allows only non-authenticated users
})
</script>