Permalink
Browse files

almost got the auth flowing. and fuck you vue-resources!

  • Loading branch information...
VVNoodle committed Apr 2, 2018
1 parent 0845a2c commit d552b3c14627c6a806efce1e8b9872785b819e69

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -20,6 +20,7 @@
"cross-env": "^3.1.3",
"dotenv": "^2.0.0",
"express": "^4.14.0",
"express-vue": "^5.6.1",
"moment": "^2.17.1",
"moment-timezone": "^0.5.11",
"mongoose": "^5.0.12",
@@ -29,7 +30,6 @@
"reload": "^1.1.0",
"request": "^2.79.0",
"serialize-javascript": "^1.3.0",
"vue-resource": "^1.5.0",
"vue-router": "^3.0.1",
"vue-server-renderer": "^2.1.8"
},
@@ -1,7 +1,6 @@
require("dotenv").config({ silent: true });
const express = require("express");
const app = express();
const path = require("path");
const fs = require("fs");
const http = require("http");
@@ -10,6 +9,23 @@ const moment = require("moment-timezone");
moment.tz.setDefault("UTC");
const serialize = require("serialize-javascript");
const expressVue = require("express-vue");
const app = express();
const vueOptions = {
head: {
title: "Page Title",
meta: [
{ property: "og:title", content: "Page Title" },
{ name: "twitter:title", content: "Page Title" }
]
},
rootPath: path.join(__dirname, "/src/components/")
};
const expressVueMiddleware = expressVue.init(vueOptions);
app.use(expressVueMiddleware);
app.use(bodyParser.json());
//************************************************************************
@@ -2,8 +2,13 @@
<div>
<ul>
<li><router-link to="/" exact>Home</router-link></li>
<li><router-link to="/login" exact>Login</router-link></li>
<div v-if="this.$store.state.loggedIn">
<li><router-link to="/calendar" exact>Calendar</router-link></li>
<li><a href="/auth/logout" exact>Logout</a></li>
</div>
<div v-else>
<li><router-link to="/login" exact>Login</router-link></li>
</div>
</ul>
<router-view></router-view>
</div>
@@ -3,10 +3,28 @@
<h1>
Home
</h1>
<button @click="check">check</button>
</div>
</template>
<script>
export default {};
import axios from "axios";
export default {
created() {
axios
.create({
baseURL: "http://localhost:3000/"
})
.get("/profile")
.then(user => {
if (user) {
console.log(user.data);
this.$store.state.loggedIn = true;
} else {
console.log("bithh ass");
}
});
}
};
</script>
@@ -3,10 +3,15 @@
<h1>
Login
</h1>
<a href="/auth/google">Log in</a>
</div>
</template>
<script>
export default {};
export default {
methods: {
login() {}
}
};
</script>
@@ -1,11 +1,6 @@
const router = require("express").Router();
const passport = require("passport");
// auth login
router.get("/login", (req, res) => {
// res.render('login', { user: req.user });
res.send("HIII");
});
const path = require("path");
// auth logout
router.get("/logout", (req, res) => {
@@ -24,7 +19,8 @@ router.get(
// callback route for google to redirect to
router.get("/google/redirect", passport.authenticate("google"), (req, res) => {
res.redirect("/profile");
// res.redirect("/profile");
res.redirect("/");
});
module.exports = router;
@@ -9,7 +9,32 @@ const authCheck = (req, res, next) => {
};
router.get("/", authCheck, (req, res) => {
res.send("AT PROFILE");
// const data = {
// otherData: "Something Else"
// };
// const vueOptions = {
// template: {
// html: {
// start: "<!DOCTYPE html><html>",
// end: "</html>"
// },
// body: {
// start: "<body>",
// end: "</body>"
// },
// template: {
// start: '<div id="app">',
// end: "</div>"
// }
// },
// head: {
// title: "Hello this is a global title",
// scripts: [{ src: "https://example.com/script.js" }],
// styles: [{ style: "/assets/rendered/style.css" }]
// }
// };
// res.renderVue("Home.vue", data, vueOptions);
res.json(req.user);
});
module.exports = router;
@@ -1,13 +1,17 @@
import App from "./components/App.vue";
import Home from "./components/Home.vue";
import Home from "./components/Login.vue";
import Login from "./components/Login.vue";
import Calendar from "./components/Calendar.vue";
export default [
{
path: "/",
component: Home
},
{
path: "/login",
component: Login
},
{
path: "/calendar",
component: Calendar
@@ -15,7 +15,8 @@ export default new Vuex.Store({
y: 0,
active: false,
events: [],
time: moment()
time: moment(),
loggedIn: false
},
mutations: {
setCurrentMonth(state, payload) {
@@ -1,11 +1,9 @@
import Vue from "vue";
import VueRouter from "vue-router";
import VueResource from "vue-resource";
import Routes from "./routes";
import "./style.scss";
import store from "./store/store";
Vue.use(VueResource);
Vue.use(VueRouter);
import moment from "moment-timezone";

0 comments on commit d552b3c

Please sign in to comment.