Skip to content

Commit 5b09abf

Browse files
committed
Before error fix Gogle login
1 parent 38e7b6f commit 5b09abf

File tree

12 files changed

+131
-197
lines changed

12 files changed

+131
-197
lines changed

exit

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
40b74bc 2021-05-25 | Fix test edit home (HEAD -> dev)
2+
845161e 2021-05-24 | add logout
3+
c42d471 2021-05-21 | Finish update post
4+
031c880 2021-05-21 | make delete user
5+
d5f12ce 2021-05-19 | Post adeed
6+
dcfe477 2021-05-18 | mail.ru and git login add
7+
701f055 2021-05-18 | Add login User images
8+
63bf2b6 2021-05-15 | google login done
9+
d1e2af6 2021-05-14 | delete user done
10+
02dcd14 2021-05-14 | avatar changed update done
11+
c265989 2021-05-14 | Starting Avatar update
12+
3e38a50 2021-05-09 | Edit User forms done
13+
8b5a8d9 2021-05-09 | before add flex on Welcome
14+
58e0ff6 2021-05-08 | add profile
15+
ba5162a 2021-05-08 | add dynamic layouts
16+
8d773bd 2021-05-08 | Start branch commit
17+
a9d6394 2021-05-08 | Before make new branch for Dynamic layouts (master)
18+
6496260 2021-05-07 | payload decode get user by id private route
19+
81a2f4c 2021-05-07 | fix fetch
20+
582b43a 2021-05-06 | register done
21+
40a6905 2021-05-06 | finish to login test
22+
f60583d 2021-05-06 | before add cors
23+
ace9ea7 2021-05-05 | add mongoose and donet
24+
d410778 2021-05-05 | before add express
25+
3bc32d1 2021-05-05 | Add Register Form
26+
6e02827 2021-05-03 | make login form
27+
14d3daa 2021-05-03 | add app and router
28+
3512ea8 2021-05-03 | add pug
29+
0da95a1 2021-05-03 | add vuetify
30+
0a11f28 2021-05-03 | init
31+
025c7df 2021-05-03 | init

server/users/models/User.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const mongoose = require("mongoose");
22
const Schema = mongoose.Schema;
3-
3+
//const Post = mongoose.model("Post");
44
// Create Schema
55
const userSchema = new Schema({
66
name: {
@@ -49,6 +49,22 @@ const userSchema = new Schema({
4949
userSchema.statics.findByEmail = function(email) {
5050
return this.find({ email: email });
5151
};
52+
53+
userSchema.pre('remove', function(next) {
54+
// Remove all the docs that refers
55+
this.model('Post').remove({ author: this._id }, next());
56+
});
57+
58+
userSchema.pre('save', function(next) {
59+
if (!this.isNew) return next();
60+
61+
if (!validatePresenceOf(this.password) && !this.skipValidation()) {
62+
next(new Error('Invalid password'));
63+
} else {
64+
next();
65+
}
66+
});
67+
5268
/*
5369
userSchema.statics.findById = function(id) {
5470
return super.findById(id).then(result => {
@@ -81,6 +97,8 @@ userSchema.statics.list = function(perPage, page) {
8197

8298
userSchema.statics.removeById = function(id) {
8399
return new Promise((resolve, reject) => {
100+
101+
84102
this.deleteOne({ _id: id }, err => {
85103
if (err) {
86104
reject(err);

src/App.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export default {
2323
},
2424
watch: {
2525
$route(to) {
26-
// set layout by route meta
26+
2727
if (to.meta.layout !== undefined) {
2828
let isAuth = this.getToken()
29-
console.log( " APP.vue is Auth ", this.getToken(),to)
29+
3030
if (isAuth && to.name=="Home") {
3131
this.layout = "LayoutMembers"
3232
} else {
@@ -40,9 +40,6 @@ export default {
4040
4141
}
4242
</script>
43-
<!-- <style>
44-
@import 'https://unpkg.com/we-do-chart/we-do-chart.min.css'
45-
</style> -->
4643

4744
<style lang="stylus">
4845

src/components/HelloWorld.vue

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/components/LayoutMembers.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default {
6969
setUserInfo() {
7070
if (localStorage.getItem('LoggedUser')) {
7171
let u = JSON.parse(localStorage.getItem('LoggedUser'))
72-
console.log("layoutMembers ", u.user.name)
72+
7373
this.userName= u.user.name
7474
this.msg= u.user.name+", Welcome!"
7575
if (u.user.profilePicture.length>0){

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import dotenv from 'dotenv'
1010

1111
dotenv.config()
1212

13-
console.log("VUE_APP_BACKEND_URL=" , process.env.VUE_APP_BACKEND_URL)
13+
//console.log("VUE_APP_BACKEND_URL=" , process.env.VUE_APP_BACKEND_URL)
1414
Vue.config.productionTip = false
1515

1616
Vue.component("my-icon", {

src/plugins/global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default Vue.mixin({
99
setUserInfo() {
1010
if (localStorage.getItem('LoggedUser')) {
1111
let u = JSON.parse(localStorage.getItem('LoggedUser'))
12-
console.log("layoutMembers ", u.user.name)
12+
1313
return u.user.name+", Welcome!"
1414
} else {
1515
console.log("layoutMembers Ops Now User")

src/router/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,12 @@ const routes = [
1515
title: 'Home',
1616
layout:'LayoutGuest'
1717
}
18-
// children: [
19-
// {
20-
// path: ':id',
21-
// component: Home,
22-
// // only authenticated users can create posts
23-
// meta: {
24-
// requiresAuth: true,
25-
// layout:'LayoutMembers',
26-
// title: 'Home'
27-
// }
28-
// }
29-
// ]
18+
3019
},
3120
{
3221
path: '/about',
3322
name: 'About',
34-
// route level code-splitting
35-
// this generates a separate chunk (about.[hash].js) for this route
36-
// which is lazy-loaded when the route is visited.
23+
3724
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
3825
meta: {
3926
visible: false,

src/views/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
v-container
44
v-row.pa-5(justify="space-around")
55
v-sheet.mt-10.rounded-xl( width="100%" height="350" elevation="13" )
6-
div.text-h2.pa-2(class="ma-3 text-center brown--text text--lighten-2" ) Best publisher service !
6+
div.text-h2.pa-2(class="ma-3 text-center brown--text text--lighten-2 font-weight-medium" ) Best publisher service !
77
div.text-body-1.pa-10(class="ml-5 text-left indigo--text text--darken-5" ) Start right now register and publish your thought for the world. Let others become know how things getting really on.
88
</template>
99

src/views/Login.vue

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,20 @@ v-main.grey.lighten-3
3939

4040
<script>
4141
import jwt_decode from "jwt-decode";
42-
// import mdiRu from "@/assets/mail_ru_logo.ico";
42+
4343
export default {
4444
data: () => ({
4545
show: false,
4646
text: "Ole",
4747
name: "todhruva@mail.ru",
4848
pwd: "qwerexQ1"
4949
}),
50-
// components: {
51-
// 'mdi-ru':mdiRu
52-
// },
50+
5351
mounted() {
5452
this.$nextTick(function () {
5553
let q = this.$route.query.token
5654
let qq = this.$route.query.refresh_token
57-
console.log( qq, " <----Redirect login ", q)
55+
5856
if (q && qq){
5957
this.saveTokens('Bearer '+ q,qq);
6058
this.$router.push({ name: 'Welcome',params:{ token: 'Bearer '+ q} });
@@ -63,12 +61,8 @@ v-main.grey.lighten-3
6361
},
6462
methods: {
6563
async login (){
66-
console.log(" Logins")
67-
//let data = JSON.stringify({"email": "sdf@dfg.ru", "password": "Textual content"});
68-
//JSON.stringify({email: "sdf@dfg.ru", password: 'Textual content'})
69-
//'http://localhost:5000/api/auth/login2'
70-
// 'http://localhost:3000/getViewLog'
71-
const rawResponse = await fetch('http://localhost:5000/api/auth/login', {
64+
65+
await fetch('http://localhost:5000/api/auth/login', {
7266
method: 'POST',
7367
headers: {
7468
'Accept': 'application/json',
@@ -81,49 +75,30 @@ v-main.grey.lighten-3
8175
})
8276
.then(response => response.json())
8377
.then(data => {
84-
console.log('Success:', data);
85-
//const userId = '123'
78+
8679
let u = jwt_decode(data.token.split(' ')[1]);
87-
console.log(u)
80+
8881
localStorage.setItem('LoggedUser',JSON.stringify({jwt:data.token,uJwt:data.refresh_token,user:u}));
8982
this.$route.meta.visible=true
9083
91-
this.$router.options.routes.forEach(a => (console.log(a)))
84+
//this.$router.options.routes.forEach(a => (console.log(a)))
9285
this.$router.options.routes.forEach(a => {
9386
if (a.meta && a.meta.visible) a.meta.visible=true
9487
})
9588
this.$router.push({ name: 'Welcome',params:{ token: data.token} });
9689
})
9790
.catch((error) => {
98-
console.error('Error121212:', error);
91+
9992
return error
10093
});
101-
console.log("login=",rawResponse);
94+
10295
},
10396
saveTokens(token,uJwt){
10497
let u =(token.split(' ').length>1)? jwt_decode(token.split(' ')[1]):jwt_decode(token);
105-
console.log(" saveTokens Goog",u)
98+
10699
localStorage.setItem('LoggedUser',JSON.stringify({jwt:token,uJwt:uJwt,user:u}));
107100
},
108-
async toGoogle (){
109-
console.log(" toGoogle")
110-
await fetch('http://localhost:5000/api/auth/google', {
111-
method: 'GET',
112-
headers: {
113-
'Accept': 'application/json',
114-
'Content-Type': 'application/json;charset=utf-8'
115-
},
116-
})
117-
.then(response => response.json())
118-
.then(data => {
119-
console.error(' Data:', data);
120-
})
121-
.catch((error) => {
122-
console.error('Error Google:', error);
123-
return error
124-
});
125-
}
126-
101+
127102
}
128103
129104
//~~~~~~~~~~~~~~~

src/views/Post.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
this.$nextTick(function () {
7272
7373
this.myID=this.myIDis();
74-
console.log( this.myIDis(), "<----myIDS ",);
74+
7575
})
7676
},
7777
watch: {
@@ -80,7 +80,7 @@
8080
this.content = ""
8181
this.title = ""
8282
setTimeout( ()=> {this.$refs.form.resetValidation()} ,50)
83-
console.log("Dialog Close")
83+
8484
}
8585
}
8686
},
@@ -90,7 +90,7 @@
9090
const valid = this.$refs.form.validate();
9191
if(valid) {
9292
if (!this.validToken ) this.validToken = this.getToken()
93-
console.log( " Get token from store @@@" ,this.validToken)
93+
9494
if (!this.validToken ){
9595
this.$router.push({ name: 'Login',params:{ msg: "Please reLogin"} });
9696
return

0 commit comments

Comments
 (0)