├── .browserslistrc
├── babel.config.js
├── postcss.config.js
├── public
├── favicon.ico
└── index.html
├── src
├── assets
│ └── logo.png
├── views
│ ├── About.vue
│ ├── Home.vue
│ ├── SignUp.vue
│ └── Login.vue
├── App.vue
├── main.js
├── router.js
└── components
│ └── HelloWorld.vue
├── .editorconfig
├── .gitignore
├── .eslintrc.js
├── README.md
└── package.json
/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 | not ie <= 8
4 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/app',
4 | ],
5 | };
6 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {},
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silvanavlima/vue-auth-firebase/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silvanavlima/vue-auth-firebase/HEAD/src/assets/logo.png
--------------------------------------------------------------------------------
/src/views/About.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
This is an about page
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.{js,jsx,ts,tsx,vue}]
2 | indent_style = space
3 | indent_size = 2
4 | end_of_line = lf
5 | trim_trailing_whitespace = true
6 | insert_final_newline = true
7 | max_line_length = 100
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | # local env files
6 | .env.local
7 | .env.*.local
8 |
9 | # Log files
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 |
14 | # Editor directories and files
15 | .idea
16 | .vscode
17 | *.suo
18 | *.ntvs*
19 | *.njsproj
20 | *.sln
21 | *.sw*
22 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: [
7 | // 'plugin:vue/essential',
8 | // '@vue/airbnb',
9 | ],
10 | rules: {
11 | // 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12 | // 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13 | },
14 | parserOptions: {
15 | parser: 'babel-eslint',
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-auth-firebase
2 |
3 | ## Project setup
4 | ```
5 | npm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | npm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | npm run build
16 | ```
17 |
18 | ### Run your tests
19 | ```
20 | npm run test
21 | ```
22 |
23 | ### Lints and fixes files
24 | ```
25 | npm run lint
26 | ```
27 |
28 | ### Customize configuration
29 | See [Configuration Reference](https://cli.vuejs.org/config/).
30 |
--------------------------------------------------------------------------------
/src/views/Home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-auth-firebase
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Home |
5 | About
6 |
7 |
8 |
9 |
10 |
11 |
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-auth-firebase",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "firebase": "^5.9.2",
12 | "vue": "^2.6.6",
13 | "vue-router": "^3.0.1"
14 | },
15 | "devDependencies": {
16 | "@vue/cli-plugin-babel": "^3.5.0",
17 | "@vue/cli-plugin-eslint": "^3.5.0",
18 | "@vue/cli-service": "^3.5.0",
19 | "@vue/eslint-config-airbnb": "^4.0.0",
20 | "babel-eslint": "^10.0.1",
21 | "eslint": "^5.8.0",
22 | "eslint-plugin-vue": "^5.0.0",
23 | "vue-template-compiler": "^2.5.21"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import App from './App.vue';
3 | import router from './router';
4 | import firebase from 'firebase';
5 |
6 | Vue.config.productionTip = false;
7 |
8 | // Initialize Firebase
9 | var config = {
10 | apiKey: 'AIzaSyC8q3jql-ZXK3iprsoIFZ1NnYRgMmeTAIw',
11 | authDomain: 'vue-auth-firebase-7d733.firebaseapp.com',
12 | databaseURL: 'https://vue-auth-firebase-7d733.firebaseio.com',
13 | projectId: 'vue-auth-firebase-7d733',
14 | storageBucket: 'vue-auth-firebase-7d733.appspot.com',
15 | messagingSenderId: '93229610542'
16 | };
17 | firebase.initializeApp(config);
18 |
19 | let app = '';
20 | firebase.auth().onAuthStateChanged(() => {
21 | if (!app) {
22 | app = new Vue({
23 | router,
24 | render: h => h(App)
25 | }).$mount('#app');
26 | }
27 | });
28 |
--------------------------------------------------------------------------------
/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | import firebase from 'firebase';
4 |
5 | import Home from './views/Home.vue';
6 | import Login from './views/Login';
7 | import SignUp from './views/SignUp';
8 |
9 | Vue.use(Router);
10 |
11 | const router = new Router({
12 | routes: [
13 | {
14 | path: '*',
15 | redirect: '/login'
16 | },
17 | {
18 | path: '/',
19 | redirect: '/login'
20 | },
21 | {
22 | path: '/login',
23 | name: 'Login',
24 | component: Login
25 | },
26 | {
27 | path: '/registrar',
28 | name: 'SignUp',
29 | component: SignUp
30 | },
31 | {
32 | path: '/home',
33 | name: 'Home',
34 | component: Home,
35 | meta: {
36 | requiresAuth: true
37 | }
38 | }
39 | ]
40 | });
41 |
42 | router.beforeEach((to, from, next) => {
43 | const currentUser = firebase.auth().currentUser;
44 | const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
45 |
46 | if (requiresAuth && !currentUser) next('login');
47 | else if (!requiresAuth && currentUser) next('home');
48 | else next();
49 | });
50 |
51 | export default router;
52 |
--------------------------------------------------------------------------------
/src/views/SignUp.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Crie uma nova conta
4 |
9 |
10 |
15 |
16 |
17 |
18 | ou retorne ao
19 | login.
20 |
21 |
22 |
23 |
24 |
50 |
51 |
79 |
--------------------------------------------------------------------------------
/src/views/Login.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Login
4 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
20 | Você não tem conta?
21 |
22 | crie uma conta
23 |
24 |
25 |
26 |
27 |
28 |
54 |
55 |
87 |
--------------------------------------------------------------------------------
/src/components/HelloWorld.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{ msg }}
4 |
5 | For a guide and recipes on how to configure / customize this project,
6 | check out the
7 | vue-cli documentation.
8 |
9 |
Installed CLI Plugins
10 |
14 |
Essential Links
15 |
22 |
Ecosystem
23 |
30 |
31 |
32 |
33 |
41 |
42 |
43 |
59 |
--------------------------------------------------------------------------------