feat(auth): split login_name and display_name for better oauth2/guest user handling
This commit is contained in:
parent
e0689143c4
commit
332086d5e2
8 changed files with 24 additions and 18 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 ?
|
||||
|
|
|
|||
|
|
@ -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...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue