Platon
Platon
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
I don’t expect this to be a built in solution as it’s kinda niche, however think the findUser solution is pretty open ended and can solve other problems at the same time
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Totally appreciate all the time you’ve spent on this so far
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Did you see the fork I sent over ?
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Totally get ya
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Good idea though
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
That system you mentioned would require a complete architectural change, and although it does give many benefits it’s also a lot of work
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Either way though, the solution I’ve provided offers more flexibility I believe
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
@Firro this is the exact system we’re migrating thousands of our customers from, it ends up being really expensive and more difficult to maintain than having on one system
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
My laptops struggling to keep up with typescript on the better-auth project so struggling to see if everything's been applied properly, can give it a better go later if you're fond of the idea?
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
I.e. findUser: (ctx, type) => { ... if (user && type === "signUp") throw new Error("Existing user with the same email found on this store")
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Can potentially open it up a bit more by also passing through the function being used as a second parameter to findUser, and based on that, we can throw custom errors if a user is found
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Just for context, this is how I'm using it: findUser: async (ctx) => { const storeId = getStore(ctx) console.log({storeId}) const user = await prisma.user.findFirst({ where: { storeId, email: ctx.body.email } }); console.log({user}) return user; } Where the getStore function looks at the Host from the ctx headers, in order to get the storeId As you can hopefully see though, it leaves it pretty open ended to many other use-cases
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
https://github.com/better-auth/better-auth/pull/2342 I'm sure it's a little away from being production ready for you guys, but this is the gist of it basiclly - working locally for my use case perfectly!
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
I'm not saying you override existing behaviour, none of that changes, just an config option where it can be overwridden with custom logic to support any type of auth really
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Maybe the way the system is built won't handle that easily though
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
It's basically a really flexible solution to logins
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Would it be worth me giving it a go and making a pull request, to see if I can do it cleanly?
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
The pros of this btw: - Can replace username login plugin - Can use this instead of the email login method, just match it with the body.email internally - Can use for other methods that people might want, i.e. login with phone number / password - Can be used for all the above together (login with either username, phone number, email) And finally... - Can allow for multi tenant setups There's probably a lot more that I'm not thinking of 🙂
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
Ok fair enough just a thought
86 replies
BABetter Auth
Created by Platon on 4/17/2025 in #help
Anyway to allow shared emails?
I imagine it as a function that takes in ctx, and spits out a user, and this basicly overrides the internalAdapter.findUserByEmail if set
86 replies