mirror of
https://github.com/strapi/strapi.git
synced 2025-07-29 03:50:26 +00:00
Merge pull request #11660 from strapi/v4/fix-sso-query
[V4] Fix sso existing user query
This commit is contained in:
commit
aaef74b58a
@ -27,7 +27,7 @@ const authenticate = async (ctx, next) => {
|
||||
return ctx.redirect(redirectUrls.error);
|
||||
}
|
||||
|
||||
const user = await getService('user').findOne({ email: profile.email });
|
||||
const user = await getService('user').findOneByEmail(profile.email);
|
||||
const scenario = user ? existingUserScenario : nonExistingUserScenario;
|
||||
|
||||
return scenario(ctx, next)(user || profile, provider);
|
||||
|
@ -180,6 +180,19 @@ const findOne = async (id, populate = ['roles']) => {
|
||||
return strapi.entityService.findOne('admin::user', id, { populate });
|
||||
};
|
||||
|
||||
/**
|
||||
* Find one user by its email
|
||||
* @param {string} id email
|
||||
* @param {string || string[] || object} populate
|
||||
* @returns
|
||||
*/
|
||||
const findOneByEmail = async (email, populate = []) => {
|
||||
return strapi.query('admin::user').findOne({
|
||||
where: { email },
|
||||
populate,
|
||||
});
|
||||
};
|
||||
|
||||
/** Find many users (paginated)
|
||||
* @param query
|
||||
* @returns {Promise<user>}
|
||||
@ -309,6 +322,7 @@ module.exports = {
|
||||
register,
|
||||
sanitizeUser,
|
||||
findOne,
|
||||
findOneByEmail,
|
||||
findPage,
|
||||
deleteById,
|
||||
deleteByIds,
|
||||
|
Loading…
x
Reference in New Issue
Block a user