diff --git a/components/Login.vue b/components/Login.vue index 2fa5f4b8..6bce51fd 100644 --- a/components/Login.vue +++ b/components/Login.vue @@ -66,6 +66,8 @@ export default { try { this.loading = true 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 Message({ message: this.$t('login.ok'), showClose: true, type: 'success' }) this.close() diff --git a/server/api/controller/user.js b/server/api/controller/user.js index e39810ea..a5b40c3a 100644 --- a/server/api/controller/user.js +++ b/server/api/controller/user.js @@ -201,7 +201,7 @@ const userController = { async current (req, res) { 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) }, diff --git a/server/api/models/user.js b/server/api/models/user.js index 55566f7e..59b91d51 100644 --- a/server/api/models/user.js +++ b/server/api/models/user.js @@ -34,7 +34,7 @@ module.exports = (sequelize, DataTypes) => { }, { scopes: { withoutPassword: { - attributes: { exclude: ['password', 'recover_code'] } + attributes: { exclude: ['password', 'recover_code', 'rsa'] } } } })