mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-27 15:05:38 -04:00
[user] reload $user when opening /account (some old avatars lagging behind in the token on other locales)
This commit is contained in:
parent
337cf68b5b
commit
4a50b4b4f1
@ -226,6 +226,10 @@
|
|||||||
async mounted() {
|
async mounted() {
|
||||||
this.profiles = (await this.$axios.$get(`/profile/get/${this.$user().username}`)).profiles;
|
this.profiles = (await this.$axios.$get(`/profile/get/${this.$user().username}`)).profiles;
|
||||||
this.socialConnections = await this.$axios.$get(`/user/social-connections`);
|
this.socialConnections = await this.$axios.$get(`/user/social-connections`);
|
||||||
|
const user = await this.$axios.$get(`/user/current`);
|
||||||
|
if (user) {
|
||||||
|
this.$store.commit('setToken', user.token);
|
||||||
|
}
|
||||||
|
|
||||||
if (process.client) {
|
if (process.client) {
|
||||||
const redirectTo = window.sessionStorage.getItem('after-login');
|
const redirectTo = window.sessionStorage.getItem('after-login');
|
||||||
|
@ -250,6 +250,27 @@ const router = Router();
|
|||||||
|
|
||||||
router.use(handleErrorAsync(reloadUser));
|
router.use(handleErrorAsync(reloadUser));
|
||||||
|
|
||||||
|
router.get('/user/current', handleErrorAsync(async (req, res) => {
|
||||||
|
if (!req.user) {
|
||||||
|
res.clearCookie('token');
|
||||||
|
return res.json(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
let dbUser = await req.db.get(SQL`SELECT * FROM users WHERE id = ${req.user.id}`);
|
||||||
|
|
||||||
|
if (!dbUser) {
|
||||||
|
res.clearCookie('token');
|
||||||
|
return res.json(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = await issueAuthentication(req.db, dbUser, false);
|
||||||
|
res.cookie('token', token, cookieSettings);
|
||||||
|
req.rawUser = jwt.validate(token);
|
||||||
|
req.user = req.rawUser;
|
||||||
|
|
||||||
|
return res.json({...req.user, token});
|
||||||
|
}));
|
||||||
|
|
||||||
router.post('/user/init', handleErrorAsync(async (req, res) => {
|
router.post('/user/init', handleErrorAsync(async (req, res) => {
|
||||||
if (req.body.usernameOrEmail && isSpam(req.body.usernameOrEmail || '')) {
|
if (req.body.usernameOrEmail && isSpam(req.body.usernameOrEmail || '')) {
|
||||||
req.socket.end();
|
req.socket.end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user