[fix] auth user
This commit is contained in:
parent
6d9f6699ef
commit
a2505e913f
3 changed files with 4 additions and 2 deletions
|
@ -66,6 +66,8 @@ export default {
|
||||||
try {
|
try {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
await this.$auth.loginWith('local', { data: { email: this.email, password: this.password } })
|
await this.$auth.loginWith('local', { data: { email: this.email, password: this.password } })
|
||||||
|
const user = await this.$axios.get('/auth/user')
|
||||||
|
this.$auth.setUser(user.data)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
Message({ message: this.$t('login.ok'), showClose: true, type: 'success' })
|
Message({ message: this.$t('login.ok'), showClose: true, type: 'success' })
|
||||||
this.close()
|
this.close()
|
||||||
|
|
|
@ -201,7 +201,7 @@ const userController = {
|
||||||
|
|
||||||
async current (req, res) {
|
async current (req, res) {
|
||||||
if (!req.user) { return res.status(400).send('Not logged') }
|
if (!req.user) { return res.status(400).send('Not logged') }
|
||||||
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
const user = await User.scope('withoutPassword').findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
||||||
res.json(user)
|
res.json(user)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||||
}, {
|
}, {
|
||||||
scopes: {
|
scopes: {
|
||||||
withoutPassword: {
|
withoutPassword: {
|
||||||
attributes: { exclude: ['password', 'recover_code'] }
|
attributes: { exclude: ['password', 'recover_code', 'rsa'] }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue