create webapp stencil with side bar, routes and fake login
This commit is contained in:
21
cmd/cli/templates/vue/authentication.ts.tmpl
Normal file
21
cmd/cli/templates/vue/authentication.ts.tmpl
Normal file
@ -0,0 +1,21 @@
|
||||
import { ref } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const useAuthenticationStore = defineStore('authentication', () => {
|
||||
// TODO: this should be replaced with a request to the server to check if the user is authenticated
|
||||
const isAuthenticated = ref(localStorage.getItem('isAuthenticated') === 'true');
|
||||
|
||||
function login() {
|
||||
// TODO: make a request to the server to authenticate the user
|
||||
isAuthenticated.value = true;
|
||||
localStorage.setItem('isAuthenticated', 'true');
|
||||
}
|
||||
|
||||
function logout() {
|
||||
// TODO: make a request to the server to log out the user
|
||||
isAuthenticated.value = false;
|
||||
localStorage.setItem('isAuthenticated', 'false');
|
||||
}
|
||||
|
||||
return { isAuthenticated, login, logout };
|
||||
});
|
Reference in New Issue
Block a user