Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Account Fixes #123

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export const config: Config = {
s3: {
endpoint: process.env.PN_ACT_CONFIG_S3_ENDPOINT || '',
key: process.env.PN_ACT_CONFIG_S3_ACCESS_KEY || '',
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || ''
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '',
region: process.env.PN_ACT_CONFIG_S3_REGION || '',
forcePathStyle: process.env.PN_ACT_CONFIG_S3_FORCE_PATH_STYLE === 'true'
},
hcaptcha: {
secret: process.env.PN_ACT_CONFIG_HCAPTCHA_SECRET || ''
Expand Down Expand Up @@ -195,6 +197,11 @@ if (!config.s3.secret) {
disabledFeatures.s3 = true;
}

if (!config.s3.region) {
LOG_WARN('Failed to find S3 region config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_REGION environment variable');
disabledFeatures.s3 = true;
}

if (!config.server_environment) {
LOG_WARN('Failed to find server environment. To change the environment, set the PN_ACT_CONFIG_SERVER_ENVIRONMENT environment variable. Defaulting to prod');
config.server_environment = 'prod';
Expand Down
9 changes: 5 additions & 4 deletions src/services/api/routes/v1/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,16 @@ router.post('/', async (request: express.Request, response: express.Response): P
await pnid.save({ session });

await session.commitTransaction();
} catch (error) {
} catch (error: any) {
LOG_ERROR('[POST] /v1/register: ' + error);
if (error.stack) console.error(error.stack);

await session.abortTransaction();

response.status(400).json({
response.status(500).json({
app: 'api',
status: 400,
error: 'Password must have combination of letters, numbers, and/or punctuation characters'
status: 500,
error: 'Internal server error'
});

return;
Expand Down
2 changes: 2 additions & 0 deletions src/types/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface Config {
endpoint: string;
key: string;
secret: string;
region: string;
forcePathStyle: boolean;
};
hcaptcha: {
secret: string;
Expand Down
2 changes: 2 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let s3: S3;
if (!disabledFeatures.s3) {
s3 = new S3({
endpoint: config.s3.endpoint,
forcePathStyle: config.s3.forcePathStyle,
region: config.s3.region,

credentials: {
accessKeyId: config.s3.key,
Expand Down