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

Fix PiCT reported bugs + build enhancements (14) #46

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion backend/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

# Backend CI/CD Process
- name: Install Dependencies for Backend
run: npm install
run: npm ci

- name: Execute Tests for Backend
run: npm run test -- --passWithNoTests
5 changes: 5 additions & 0 deletions backend/src/config/docs/UsersSchema.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer

schemas:
AuthenticateUserRq:
type: object
Expand Down
7 changes: 4 additions & 3 deletions backend/src/middlewares/isPioneerFound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ export const isPioneerFound = async (
res: Response,
next: NextFunction
) => {
const auth = req.body.pioneerAuth;
const authHeader = req.headers.authorization;
const tokenFromHeader = authHeader && authHeader.split(" ")[1];

try {
logger.info("Verifying user's access token with the /me endpoint.");
// Verify the user's access token with the /me endpoint:
const me = await platformAPIClient.get(`/v2/me`, {
headers: { 'Authorization': `Bearer ${auth.accessToken}` }
headers: { 'Authorization': `Bearer ${ tokenFromHeader }` }
});

if (me) {
if (me && me.data) {
const user = {
pi_uid: me.data.uid,
pi_username: me.data.username,
Expand Down
19 changes: 3 additions & 16 deletions backend/src/routes/user.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,9 @@ const userRoutes = Router();
* post:
* tags:
* - User
* summary: Authenticate the user's access token
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* pioneerAuth:
* type: object
* properties:
* accessToken:
* type: string
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NjZiYmFlNGEwNWJjYzNkOGRmYWI1NjMiLCJpYXQiOjE3MTgzMzk0MDksImV4cCI6MTcyMDkzMTQwOX0.gFz-EdHoOqz3-AuFX5R4uGtruFaTMH8sTOXEX-3c7yw
* required:
* - pioneerAuth
* summary: Authenticate the user's access token *
* security:
* - BearerAuth: []
* responses:
* 200:
* description: Successful response
Expand Down
6 changes: 3 additions & 3 deletions backend/src/services/reviewFeedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const getReviewFeedback = async (
return {
givenReviews: updatedGivenFeedbackList,
receivedReviews: updatedReceivedFeedbackList
} as CompleteFeedback;
} as unknown as CompleteFeedback;
} catch (error) {
logger.error(`Failed to retrieve reviews for reviewReceiverID ${review_receiver_id}:`, error);
throw new Error('Failed to retrieve reviews; please try again later');
Expand Down Expand Up @@ -161,8 +161,8 @@ export const getReviewFeedbackById = async (review_id: string): Promise<{
const mainReview = { ...reviewFeedback.toObject(), giver: giverName, receiver: receiverName };

return {
review: mainReview as IReviewFeedbackOutput,
replies: updatedReplyList as IReviewFeedbackOutput[],
review: mainReview as unknown as IReviewFeedbackOutput,
replies: updatedReplyList as unknown as IReviewFeedbackOutput[],
};
} catch (error) {
logger.error(`Failed to retrieve review for reviewID ${review_id}:`, error);
Expand Down
2 changes: 1 addition & 1 deletion frontend/.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

# Frontend CI/CD Process
- name: Install Dependencies for Frontend
run: npm install
run: npm ci

- name: Build Frontend
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY ./package-lock.json /app/package-lock.json

WORKDIR /app

RUN npm install
RUN npm ci

# Copy the resources needed to build the app
COPY ./src /app/src
Expand Down
10 changes: 9 additions & 1 deletion frontend/context/AppContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ const AppContextProvider = ({ children }: AppContextProviderProps) => {
try {
setIsSigningInUser(true)
const pioneerAuth: AuthResult = await window.Pi.authenticate(['username', 'payments'], onIncompletePaymentFound);
const res = await axiosClient.post("/users/authenticate", {pioneerAuth});
const res = await axiosClient.post(
"/users/authenticate",
{}, // empty body
{
headers: {
Authorization: `Bearer ${pioneerAuth.accessToken}`,
},
}
);

if (res.status === 200) {
setAuthToken(res.data?.token)
Expand Down
19 changes: 19 additions & 0 deletions frontend/i18n/i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Can be imported from a shared config
export const locales = [
'ar',
'en',
'en-GB',
'es',
'ewe-BJ',
'fon-BJ',
'fr',
'hau-NG',
'yor-NG',
'ja',
'ko',
'vi',
'zh-CN',
'zh-TW'
] as const;

export const defaultLocale = 'en';
21 changes: 2 additions & 19 deletions frontend/src/i18n.ts → frontend/i18n/request.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
import { notFound } from 'next/navigation';
import { getRequestConfig } from 'next-intl/server';

// Can be imported from a shared config
export const locales = [
'ar',
'en',
'en-GB',
'es',
'ewe-BJ',
'fon-BJ',
'fr',
'hau-NG',
'ko',
'vi',
'zh-CN',
'zh-TW'
] as const;

export const defaultLocale = 'en';
import { locales } from './i18n';

export default getRequestConfig(async ({ locale }) => {
// Validate that the incoming `locale` parameter is valid
Expand All @@ -26,4 +9,4 @@ export default getRequestConfig(async ({ locale }) => {
return {
messages: (await import(`../messages/${locale}.json`)).default,
};
});
});
Loading