From 352b05d6b7adc39d73a9eb615df266bc4b9d03e4 Mon Sep 17 00:00:00 2001 From: SpaceGhost Date: Wed, 13 Nov 2019 14:07:43 +0100 Subject: [PATCH 1/2] Fix no session on social Logins Because social tokens are constructed via await access.grantAccess(user, req, user.passwordHash), and password_hash was missing session could not be established. --- modules/user/server-ts/social/shared.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/user/server-ts/social/shared.js b/modules/user/server-ts/social/shared.js index 4de43a9204..f047878b6e 100644 --- a/modules/user/server-ts/social/shared.js +++ b/modules/user/server-ts/social/shared.js @@ -1,4 +1,5 @@ import { access } from '@gqlapp/authentication-server-ts'; +import bcrypt from 'bcryptjs'; import User from '../sql'; export async function onAuthenticationSuccess(req, res) { @@ -14,10 +15,13 @@ export async function onAuthenticationSuccess(req, res) { } export const registerUser = async ({ id, username, displayName, emails: [{ value }] }) => { + const passwordHash = await bcrypt.hash(id || username || displayName, 12); return User.register({ username: username || displayName, email: value, password: id, isActive: true - }); + }, + passwordHash + ); }; From e020b5f7e6606858919fa2a4644240a106c5b2c5 Mon Sep 17 00:00:00 2001 From: SpaceGhost Date: Wed, 13 Nov 2019 14:13:46 +0100 Subject: [PATCH 2/2] Update shared.js erasing old password value --- modules/user/server-ts/social/shared.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/user/server-ts/social/shared.js b/modules/user/server-ts/social/shared.js index f047878b6e..54e6f4031e 100644 --- a/modules/user/server-ts/social/shared.js +++ b/modules/user/server-ts/social/shared.js @@ -19,7 +19,6 @@ export const registerUser = async ({ id, username, displayName, emails: [{ value return User.register({ username: username || displayName, email: value, - password: id, isActive: true }, passwordHash