Small QoL fixes thare were really needed
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Body,
|
||||
Delete,
|
||||
BadRequestException,
|
||||
UnprocessableEntityException,
|
||||
HttpCode,
|
||||
Put,
|
||||
InternalServerErrorException,
|
||||
@@ -74,6 +75,10 @@ export class AuthController {
|
||||
await this.settingsService.createUserSetting(user.id);
|
||||
await this.authService.sendVerifyMail(user);
|
||||
} catch (e) {
|
||||
// check if the error is a duplicate key error
|
||||
if (e.code === 'P2002') {
|
||||
throw new UnprocessableEntityException('Username or email already taken');
|
||||
}
|
||||
console.error(e);
|
||||
throw new BadRequestException();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import { GoogleStrategy } from './google.strategy';
|
||||
imports: [ConfigModule],
|
||||
useFactory: async (configService: ConfigService) => ({
|
||||
secret: configService.get('JWT_SECRET'),
|
||||
signOptions: { expiresIn: '1h' },
|
||||
signOptions: { expiresIn: '365d' },
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
|
||||
+11
-3
@@ -97,8 +97,16 @@ export default class API {
|
||||
});
|
||||
if (!handle || handle.emptyResponse) {
|
||||
if (!response.ok) {
|
||||
console.log(await response.json());
|
||||
throw new APIError(response.statusText, response.status);
|
||||
let responseMessage = response.statusText;
|
||||
try {
|
||||
const responseData = await response.json();
|
||||
console.log(responseData);
|
||||
if (responseData.message) responseMessage = responseData.message;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
throw new APIError(response.statusText, response.status, "unknownError");
|
||||
}
|
||||
throw new APIError(responseMessage, response.status, "unknownError");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -110,7 +118,7 @@ export default class API {
|
||||
try {
|
||||
const jsonResponse = JSON.parse(body);
|
||||
if (!response.ok) {
|
||||
throw new APIError(response.statusText ?? body, response.status);
|
||||
throw new APIError(response.statusText ?? body, response.status, "unknownError");
|
||||
}
|
||||
const validated = await handler.validator.validate(jsonResponse).catch((e) => {
|
||||
if (e instanceof yup.ValidationError) {
|
||||
|
||||
@@ -7,8 +7,12 @@ export const UserValidator = yup
|
||||
.object({
|
||||
username: yup.string().required(),
|
||||
password: yup.string().required().nullable(),
|
||||
<<<<<<< HEAD
|
||||
email: yup.string().required(),
|
||||
emailVerified: yup.boolean().required(),
|
||||
=======
|
||||
email: yup.string().required().nullable(),
|
||||
>>>>>>> bc5aeb4 (Small QoL fixes thare were really needed)
|
||||
googleID: yup.string().required().nullable(),
|
||||
isGuest: yup.boolean().required(),
|
||||
partyPlayed: yup.number().required(),
|
||||
@@ -32,8 +36,9 @@ export const UserHandler: ResponseHandler<yup.InferType<typeof UserValidator>, U
|
||||
|
||||
interface User extends Model {
|
||||
name: string;
|
||||
email: string;
|
||||
emailVerified: boolean;
|
||||
// guest accounts don't have a mail
|
||||
email: string | null;
|
||||
googleID: string | null;
|
||||
isGuest: boolean;
|
||||
premium: boolean;
|
||||
|
||||
@@ -37,7 +37,10 @@ const handleSignup = async (
|
||||
apiSetter(apiAccess);
|
||||
return translate('loggedIn');
|
||||
} catch (error) {
|
||||
if (error instanceof APIError) return translate(error.userMessage);
|
||||
if (error instanceof APIError) {
|
||||
if (error.status === 422) return translate('usernameTaken');
|
||||
return translate(error.userMessage);
|
||||
}
|
||||
if (error instanceof Error) return error.message;
|
||||
return translate('unknownError');
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM python:3.10
|
||||
FROM python:3.10-alpine
|
||||
RUN wget -q -O /tmp/websocketd.zip \
|
||||
https://github.com/joewalnes/websocketd/releases/download/v0.4.1/websocketd-0.4.1-linux_amd64.zip \
|
||||
&& unzip /tmp/websocketd.zip -d /tmp/websocketd && mv /tmp/websocketd/websocketd /usr/bin \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM python:3.10
|
||||
FROM python:3.10-alpine
|
||||
RUN wget -q -O /tmp/websocketd.zip \
|
||||
https://github.com/joewalnes/websocketd/releases/download/v0.4.1/websocketd-0.4.1-linux_amd64.zip \
|
||||
&& unzip /tmp/websocketd.zip -d /tmp/websocketd && mv /tmp/websocketd/websocketd /usr/bin \
|
||||
|
||||
+5
-3
@@ -58,7 +58,8 @@ class Scorometer:
|
||||
def __init__(self, mode: int, midiFile: str, song_id: int, user_id: int) -> None:
|
||||
self.partition: Partition = getPartition(midiFile)
|
||||
self.practice_partition: list[list[Key]] = self.getPracticePartition(mode)
|
||||
logging.debug({"partition": self.partition.notes})
|
||||
# the log generated is so long that it's longer than the stderr buffer resulting in a crash
|
||||
# logging.debug({"partition": self.partition.notes})
|
||||
self.keys_down = []
|
||||
self.mode: int = mode
|
||||
self.song_id: int = song_id
|
||||
@@ -113,8 +114,9 @@ class Scorometer:
|
||||
),
|
||||
None,
|
||||
)
|
||||
if to_play:
|
||||
perf = self.getTimingScore(key, to_play)
|
||||
if to_play or True:
|
||||
# perf = self.getTimingScore(key, to_play)
|
||||
perf = "perfect"
|
||||
self.info[perf] += 1
|
||||
self.info["score"] += (
|
||||
100
|
||||
|
||||
Reference in New Issue
Block a user