icons started to work yeah
This commit is contained in:
parent
95784c9719
commit
3cccc18e9a
20 changed files with 719 additions and 8 deletions
BIN
src/auth/config/default.png
Normal file
BIN
src/auth/config/default.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
|
|
@ -2,6 +2,7 @@ import { FastifyPluginAsync } from 'fastify';
|
|||
|
||||
import { Static, Type } from 'typebox';
|
||||
import { typeResponse, isNullish, MakeStaticResponse } from '@shared/utils';
|
||||
import * as fs from 'node:fs/promises';
|
||||
|
||||
export const GuestLoginRes = {
|
||||
'500': typeResponse('failed', [
|
||||
|
|
@ -91,6 +92,7 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
|
|||
'guestLogin.failed.generic.unknown',
|
||||
);
|
||||
}
|
||||
await fs.cp('/config/default.png', `/volumes/icons/${user.id}`);
|
||||
return res.makeResponse(200, 'success', 'guestLogin.success', {
|
||||
token: this.signJwt('auth', user.id.toString()),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { FastifyPluginAsync } from 'fastify';
|
|||
import { Static, Type } from 'typebox';
|
||||
import { typeResponse, isNullish } from '@shared/utils';
|
||||
import * as oauth2 from '../../oauth2';
|
||||
import * as fs from 'node:fs/promises';
|
||||
|
||||
|
||||
export const WhoAmIRes = Type.Union([
|
||||
|
|
@ -47,6 +48,9 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
|
|||
user_name = `${orig}${Date.now()}`;
|
||||
}
|
||||
u = await this.db.createOauth2User(user_name, provider.display_name, userinfo.unique_id);
|
||||
if (u) {
|
||||
await fs.cp('/config/default.png', `/volumes/icons/${u.id}`);
|
||||
}
|
||||
}
|
||||
if (isNullish(u)) {
|
||||
return res.code(500).send('failed to fetch or create user...');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { FastifyPluginAsync } from 'fastify';
|
|||
|
||||
import { Static, Type } from 'typebox';
|
||||
import { typeResponse, isNullish, MakeStaticResponse } from '@shared/utils';
|
||||
import * as fs from 'node:fs/promises';
|
||||
|
||||
const USERNAME_CHECK: RegExp = /^[a-zA-Z_0-9]+$/;
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ const route: FastifyPluginAsync = async (fastify, _opts): Promise<void> => {
|
|||
}
|
||||
const u = await this.db.createUser(name, user_name, password);
|
||||
if (isNullish(u)) { return res.makeResponse(500, 'failed', 'signin.failed.generic'); }
|
||||
await fs.cp('/config/default.png', `/volumes/icons/${u.id}`);
|
||||
|
||||
// every check has been passed, they are now logged in, using this token to say who they are...
|
||||
const userToken = this.signJwt('auth', u.id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue