mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 07:28:21 +00:00
Merge pull request #1946 from Infisical/daniel/fix-username-unique-bug
Fix: Email confirmation during SAML login failing (edge-case)
This commit is contained in:
@@ -231,7 +231,7 @@ export const authSignupServiceFactory = ({
|
|||||||
|
|
||||||
const accessToken = jwt.sign(
|
const accessToken = jwt.sign(
|
||||||
{
|
{
|
||||||
authMethod: AuthMethod.EMAIL,
|
authMethod: authMethod || AuthMethod.EMAIL,
|
||||||
authTokenType: AuthTokenType.ACCESS_TOKEN,
|
authTokenType: AuthTokenType.ACCESS_TOKEN,
|
||||||
userId: updateduser.info.id,
|
userId: updateduser.info.id,
|
||||||
tokenVersionId: tokenSession.id,
|
tokenVersionId: tokenSession.id,
|
||||||
@@ -244,7 +244,7 @@ export const authSignupServiceFactory = ({
|
|||||||
|
|
||||||
const refreshToken = jwt.sign(
|
const refreshToken = jwt.sign(
|
||||||
{
|
{
|
||||||
authMethod: AuthMethod.EMAIL,
|
authMethod: authMethod || AuthMethod.EMAIL,
|
||||||
authTokenType: AuthTokenType.REFRESH_TOKEN,
|
authTokenType: AuthTokenType.REFRESH_TOKEN,
|
||||||
userId: updateduser.info.id,
|
userId: updateduser.info.id,
|
||||||
tokenVersionId: tokenSession.id,
|
tokenVersionId: tokenSession.id,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ type TUserServiceFactoryDep = {
|
|||||||
| "findOneUserAction"
|
| "findOneUserAction"
|
||||||
| "createUserAction"
|
| "createUserAction"
|
||||||
| "findUserEncKeyByUserId"
|
| "findUserEncKeyByUserId"
|
||||||
|
| "delete"
|
||||||
>;
|
>;
|
||||||
userAliasDAL: Pick<TUserAliasDALFactory, "find" | "insertMany">;
|
userAliasDAL: Pick<TUserAliasDALFactory, "find" | "insertMany">;
|
||||||
orgMembershipDAL: Pick<TOrgMembershipDALFactory, "find" | "insertMany">;
|
orgMembershipDAL: Pick<TOrgMembershipDALFactory, "find" | "insertMany">;
|
||||||
@@ -85,7 +86,7 @@ export const userServiceFactory = ({
|
|||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
|
|
||||||
// check if there are users with the same email.
|
// check if there are verified users with the same email.
|
||||||
const users = await userDAL.find(
|
const users = await userDAL.find(
|
||||||
{
|
{
|
||||||
email,
|
email,
|
||||||
@@ -134,6 +135,15 @@ export const userServiceFactory = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
await userDAL.delete(
|
||||||
|
{
|
||||||
|
email,
|
||||||
|
isAccepted: false,
|
||||||
|
isEmailVerified: false
|
||||||
|
},
|
||||||
|
tx
|
||||||
|
);
|
||||||
|
|
||||||
// update current user's username to [email]
|
// update current user's username to [email]
|
||||||
await userDAL.updateById(
|
await userDAL.updateById(
|
||||||
user.id,
|
user.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user