feat(auth): split login_name and display_name for better oauth2/guest user handling

This commit is contained in:
Maieul BOYER 2025-10-25 17:07:17 +02:00 committed by Maix0
parent e0689143c4
commit 332086d5e2
8 changed files with 24 additions and 18 deletions

View file

@ -31,6 +31,8 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
const noun = getRandomFromList(fastify.words.nouns);
const user = await this.db.createUser(
// no login_name => can't login
null,
`${adjective} ${noun}`,
// no password
undefined,

View file

@ -29,7 +29,7 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
void _res;
try {
const { name, password } = req.body;
const user = this.db.getUserFromName(name);
const user = this.db.getUserFromLoginName(name);
// does the user exist
// does it have a password setup ?

View file

@ -46,8 +46,8 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
if (password.length > 64) {return makeResponse('failed', 'signin.failed.password.toolong');}
// password is good too !
if (this.db.getUserFromName(name) !== undefined) {return makeResponse('failed', 'signin.failed.username.existing');}
const u = await this.db.createUser(name, password, false);
if (this.db.getUserFromLoginName(name) !== undefined) {return makeResponse('failed', 'signin.failed.username.existing');}
const u = await this.db.createUser(name, name, password, false);
if (isNullish(u)) {return makeResponse('failed', 'signin.failed.generic');}
// every check has been passed, they are now logged in, using this token to say who they are...