Skip to content

Commit 22dc1b8

Browse files
committed
Show only public info to outsiders in profile page
1 parent 301ae0e commit 22dc1b8

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed

client/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
'camelcase': [0, {
3838
'properties': 'always'
3939
}],
40-
'comma-dangle': [2, 'never'],
40+
'comma-dangle': [2, 'always-multiline'],
4141
'comma-spacing': [2, {
4242
'before': false,
4343
'after': true

client/src/views/users/components/solveCount.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ export default {
1414
props: ['username'],
1515
computed: {
1616
...mapGetters([
17-
'ojInfo'
17+
'ojInfo',
18+
'profile',
1819
]),
1920
getSolveCount() {
2021
return Object.keys(this.ojInfo).map((oj, ind) => {
2122
return {
2223
index: ind,
23-
oj
24+
oj,
2425
}
2526
})
26-
}
27+
},
2728
},
2829
async created() {
2930
if (Object.keys(this.ojInfo).length === 0) {
3031
await this.$store.dispatch(GetOjInfo)
3132
}
32-
}
33+
},
3334
}
3435
</script>
3536

client/src/views/users/components/userProfile.vue

+15-9
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,33 @@ export default {
2121
computed: {
2222
...mapGetters([
2323
'user',
24-
'profile'
24+
'profile',
2525
]),
2626
getUserFields() {
27-
return [{
27+
const ret = [{
2828
feature: 'Email',
2929
icon: 'envelope',
30-
value: this.profile.email
30+
value: this.user.email,
3131
}, {
3232
feature: 'Username',
3333
icon: 'user',
34-
value: this.profile.username
34+
value: this.profile.username,
35+
public: true,
3536
}, {
3637
feature: 'Roles',
3738
icon: 'users',
38-
value: this.profile.roles.join(', ')
39+
value: this.profile.roles.join(', '),
40+
public: true,
3941
}, {
4042
feature: 'Password',
41-
icon: 'key'
42-
}]
43-
}
44-
}
43+
icon: 'key',
44+
} ]
45+
return this.isOwner ? ret : ret.filter((x) => x.public)
46+
},
47+
isOwner() {
48+
return this.user.username === this.profile.username
49+
},
50+
},
4551
}
4652
</script>
4753

client/src/views/users/index.vue

+13-5
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,39 @@
1313
<script>
1414
import { UserProfile, SolveCount } from './components'
1515
import { FetchProfile } from '@/store/actions'
16+
import { mapGetters } from 'vuex'
1617
1718
export default {
1819
components: { UserProfile, SolveCount },
1920
props: ['username'],
2021
data() {
2122
return {
22-
loading: true
23+
loading: true,
2324
}
2425
},
26+
computed: {
27+
...mapGetters([
28+
'user',
29+
]),
30+
},
2531
watch: {
26-
'$route': 'initiateUser'
32+
'$route': 'initiateUser',
2733
},
2834
async created() {
2935
await this.initiateUser()
3036
},
3137
methods: {
3238
async initiateUser() {
39+
if (this.username === ':username') {
40+
return this.$router.push(`/user/profile/${this.user.username}`)
41+
}
3342
try {
34-
console.log('disptach profile')
3543
await this.$store.dispatch(FetchProfile, this.username)
3644
} finally {
3745
this.loading = false
3846
}
39-
}
40-
}
47+
},
48+
},
4149
}
4250
</script>
4351

0 commit comments

Comments
 (0)