Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
51f435d
GitHub Classroom Feedback
github-classroom[bot] Sep 7, 2024
d5d1198
Setting up GitHub Classroom Feedback
github-classroom[bot] Sep 7, 2024
f80b837
add deadline
github-classroom[bot] Sep 7, 2024
c30b100
PP-12: Set-Up Front End
AlyssaPng Sep 19, 2024
bc60dd0
Add Node Modules
AlyssaPng Sep 19, 2024
d98cb43
Merge pull request #4 from CS3219-AY2425S1/PP-12
zoebelle-pang Sep 19, 2024
dd45976
Create connection to mongodb client and set up env file reader
Kb-Tay Sep 19, 2024
dd7fd2d
Merge pull request #5 from CS3219-AY2425S1/PP15
Kb-Tay Sep 19, 2024
50db0b8
PP-13 [FrontEnd] User Service - Login UI
AlyssaPng Sep 19, 2024
6c0252a
Add JWT authentication
SHni99 Sep 19, 2024
42ee4d6
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 20, 2024
8c2455b
Pull main branch
AlyssaPng Sep 20, 2024
4d6c9a5
Merge pull request #6 from CS3219-AY2425S1/PP-13
zoebelle-pang Sep 20, 2024
6b7826e
PP-14 [FrontEnd] User Service - Registration UI
zoebelle-pang Sep 20, 2024
bdbf889
PP-14 update
zoebelle-pang Sep 21, 2024
b3b7f8b
Add basic question service UI
AlyssaPng Sep 21, 2024
f566407
Edit UI
AlyssaPng Sep 21, 2024
58f8152
Add drop down filters
AlyssaPng Sep 21, 2024
8d65447
Update mongodb client connection to up to date functions
Kb-Tay Sep 21, 2024
f400505
Fix warning in user controller and update user model
Kb-Tay Sep 21, 2024
86c9a42
Fix login controller warnings and response
Kb-Tay Sep 21, 2024
af6850c
Update dependencies of jwt token auth
Kb-Tay Sep 22, 2024
368cef9
Merge pull request #11 from CS3219-AY2425S1/PP-18-aaron
Kb-Tay Sep 22, 2024
dcf4c7f
Error handle when claims is nil during validation. Add question routes
Kb-Tay Sep 22, 2024
accd1ee
Add more questions into controller
Kb-Tay Sep 22, 2024
3d2bc1e
Implement refresh token route. Changed user db to only store refresh_…
Kb-Tay Sep 23, 2024
5a036ac
Add CORS middleware
SHni99 Sep 23, 2024
d5e3e1e
Edit code to improve scalability
AlyssaPng Sep 23, 2024
a995feb
Merge pull request #9 from CS3219-AY2425S1/PP-14
AlyssaPng Sep 23, 2024
5f88892
Fix Merge Conflicts
AlyssaPng Sep 24, 2024
21521b2
Fix dropdown menu bug
AlyssaPng Sep 24, 2024
03bd862
PP-21 [Frontend] Link BackEnd to FrontEnd
AlyssaPng Sep 24, 2024
dc0ea7b
Merge pull request #10 from CS3219-AY2425S1/PP-23
AlyssaPng Sep 24, 2024
14c7c33
Add email verification
SHni99 Sep 25, 2024
7de0a6e
limit port to specific host
SHni99 Sep 25, 2024
788113a
Add reset password
SHni99 Sep 25, 2024
35cf2c5
Pull main and fix conflicts
AlyssaPng Sep 26, 2024
9b19c48
Merge pull request #13 from CS3219-AY2425S1/PP-20
AlyssaPng Sep 26, 2024
55a8cbd
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 26, 2024
9566b4c
Merge pull request #12 from CS3219-AY2425S1/PP-26
AlyssaPng Sep 26, 2024
0fe1088
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 26, 2024
7bba9de
PP-21 [FrontEnd] User Service - Link Backend to Frontend
AlyssaPng Sep 26, 2024
db159b8
Create route to get user profile information
Kb-Tay Sep 26, 2024
706cf54
Add routes to retrieve and edit user information
Kb-Tay Sep 26, 2024
6be6805
Merge pull request #15 from CS3219-AY2425S1/PP-21
AlyssaPng Sep 26, 2024
3d3f3fa
Add Logout func, reset refresh token when logging out
Hwww23 Sep 26, 2024
9e1a26c
remove comments for logout
Hwww23 Sep 26, 2024
4400b38
Update reset password method
SHni99 Sep 26, 2024
deff85b
Add routes to update and retrieve user's completed questions. Create …
Kb-Tay Sep 26, 2024
8c62d4a
Merge pull request #14 from CS3219-AY2425S1/PP-27
Kb-Tay Sep 26, 2024
1515e21
Merge changes for reset password feature
Kb-Tay Sep 26, 2024
f41e57b
Make changes to check that user who are not signed in should not
Hwww23 Sep 26, 2024
f8bd04b
Merge branch 'main' into PP-25
Hwww23 Sep 26, 2024
602b944
Add in UI
AlyssaPng Sep 27, 2024
6a90cb5
Create axio instance with middleware to include tokens when accessing…
Kb-Tay Sep 27, 2024
814eae5
no message
zoebelle-pang Sep 27, 2024
6474871
Fix question request
Kb-Tay Sep 27, 2024
eabdd17
PP-33
zoebelle-pang Sep 27, 2024
7c41005
Add verify token route to redirect users to frontend reset password p…
Kb-Tay Sep 27, 2024
3a6f792
Merge pull request #18 from CS3219-AY2425S1/PP-25
Kb-Tay Sep 27, 2024
0af7bfc
Merge pull request #17 from CS3219-AY2425S1/PP-28-30
AlyssaPng Sep 27, 2024
316d969
Refactor navbar to layout
Kb-Tay Sep 27, 2024
8f902cb
Refactor navbar to layout
Kb-Tay Sep 27, 2024
e6a971f
Add UI button
AlyssaPng Sep 27, 2024
254018c
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 27, 2024
f67d422
Resolve merge conflicts
Kb-Tay Sep 27, 2024
fd4ea3b
Update backend gitignore
Kb-Tay Sep 27, 2024
25e6c55
Add toast to show success and failed messages to login and sign up pages
SHni99 Sep 27, 2024
5fc830e
Remove backend.exe
Kb-Tay Sep 27, 2024
4df859c
Change gitignore
Kb-Tay Sep 27, 2024
6702975
Resolve merge conflicts
Kb-Tay Sep 27, 2024
88b8ec8
Merge pull request #23 from CS3219-AY2425S1/PP-33-aaron
Kb-Tay Sep 27, 2024
41f77da
Fix merge conflict
SHni99 Sep 27, 2024
8c95a5f
Delete backend.exe
SHni99 Sep 27, 2024
2c89e4b
Create dashboard page. Implement navigation for sidebars
Kb-Tay Sep 28, 2024
05489c1
Merge changes with main
Kb-Tay Sep 28, 2024
13e3e4c
App queries user data upon authentication and stores in context
Kb-Tay Sep 28, 2024
ee48ff5
Add logout
AlyssaPng Sep 28, 2024
68c1543
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 28, 2024
b805de2
Fix code
AlyssaPng Sep 28, 2024
c6e397c
Add loading states for login and registration button
Kb-Tay Sep 28, 2024
f6fe99e
Create profile view
Kb-Tay Sep 28, 2024
802e1b2
Remove duplicated code
AlyssaPng Sep 28, 2024
c6cbe9b
Add axios error instance
SHni99 Sep 28, 2024
e476f61
Fix logout bug
AlyssaPng Sep 28, 2024
fc8e31b
Merge pull request #24 from CS3219-AY2425S1/PP-39
Kb-Tay Sep 28, 2024
b2c3eb5
Fix merge conflicts
AlyssaPng Sep 28, 2024
d01f029
Merge pull request #19 from CS3219-AY2425S1/PP-32
Kb-Tay Sep 28, 2024
cdc68a7
Merge with main
Kb-Tay Sep 28, 2024
3442957
Fix errors in merge
Kb-Tay Sep 28, 2024
7429864
Merge pull request #25 from CS3219-AY2425S1/PP-36
AlyssaPng Sep 28, 2024
d37d4b6
Fix filter in question table
zoebelle-pang Sep 28, 2024
dba8d04
Merge pull request #26 from CS3219-AY2425S1/PP-13-1
Hwww23 Sep 28, 2024
8347567
Add question function in backend
SHni99 Sep 28, 2024
f25a726
Remove id in output
SHni99 Sep 28, 2024
28b2ded
Added update question and delete question function in backend
Hwww23 Sep 28, 2024
3cfc4aa
Merge pull request #27 from CS3219-AY2425S1/PP-41
Kb-Tay Sep 29, 2024
e43225f
Add validation for question complexity. Checks for duplicate question…
Kb-Tay Sep 29, 2024
fb1c27b
Updated the update and delete question function to utilize only
Hwww23 Sep 29, 2024
93392af
PP-43 [FrontEnd] Question Service - Create questions + Update questio…
AlyssaPng Sep 29, 2024
71e71d7
Merge branch 'main' of https://github.com/CS3219-AY2425S1/cs3219-ay24…
AlyssaPng Sep 29, 2024
ee9266e
Remove duplicate header
AlyssaPng Sep 29, 2024
9e1b7c7
Merge pull request #30 from CS3219-AY2425S1/PP-43
zoebelle-pang Sep 29, 2024
548b6ae
PP-40
zoebelle-pang Sep 29, 2024
4c36ae8
PP-45
zoebelle-pang Sep 29, 2024
b6ae530
Create handler to submit question. Create toast to display status of …
Kb-Tay Sep 29, 2024
9edf7b0
Merge pull request #31 from CS3219-AY2425S1/PP-45
Kb-Tay Sep 29, 2024
8e14b7f
Merge pull request #29 from CS3219-AY2425S1/PP-42
Kb-Tay Sep 29, 2024
13a0e4f
Merge conflicts with main
Kb-Tay Sep 29, 2024
e32ef09
Update delete request to retrieve id from url
Kb-Tay Sep 29, 2024
86bc0bf
Merge pull request #32 from CS3219-AY2425S1/PP-46-aaron
Kb-Tay Sep 29, 2024
c3f956c
Merge branch 'main' into PP-44
Kb-Tay Sep 29, 2024
835219d
Connect update and edit request frontend to backend
Kb-Tay Sep 29, 2024
212b1ef
Fix error when no questions in db
Kb-Tay Sep 29, 2024
83d4783
Remove default of fetching user data on window focus
Kb-Tay Sep 29, 2024
d255175
Fix table style
AlyssaPng Sep 29, 2024
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
Empty file added .github/.keep
Empty file.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/bzPrOe11)
# CS3219 Project (PeerPrep) - AY2425S1
## Group: Gxx

Expand Down
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
backend.exe
backend.exe~
106 changes: 106 additions & 0 deletions backend/controllers/profileController.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package controllers

import (
"backend/models"
"context"
"log"
"net/http"

"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson"
)

func GetUserProfile(c *gin.Context) {
user_id, exists := c.Get("uid")
user := models.User{}

if !exists {
c.JSON(http.StatusInternalServerError, gin.H{"error": "user not found"})
return
}

err := userCollection.FindOne(context.TODO(), bson.M{"user_id": user_id}).Decode(&user)

if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "user not found"})
return
}

userToReturn := models.VisibleUser{
Username: user.Username,
Email: user.Email,
User_id: user.User_id,
Questions_done: user.Questions_done,
}

c.JSON(http.StatusOK, userToReturn)
}

func EditUsername(c *gin.Context) {
user_id, exists := c.Get("uid")

if !exists {
c.JSON(http.StatusInternalServerError, gin.H{"error": "user not found"})
return
}

var new_username struct {
Username string `json:"username" binding:"required"`
}

err := c.BindJSON(&new_username)

if err != nil {
if new_username.Username == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "Username cannot be empty"})
return
}

c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}

filter := bson.M{"user_id": user_id}
update := bson.M{"$set": new_username}

result, err := userCollection.UpdateOne(context.TODO(), filter, update)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to update user information", "error": err.Error()})
return
}

log.Printf("Updated %v Documents!\n", result.ModifiedCount)
c.JSON(http.StatusOK, gin.H{"message": "Username updated successfully"})
}

func AddQuestionsToProfile(c *gin.Context) {
user_id, exists := c.Get("uid")

if !exists {
c.JSON(http.StatusInternalServerError, gin.H{"error": "user not found"})
return
}

var questions struct {
Questions []int `json:"questions" binding:"required"`
}

err := c.BindJSON(&questions)

if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}

filter := bson.M{"user_id": user_id}
update := bson.M{"$push": bson.M{"questions_done": bson.M{"$each": questions.Questions}}}

result, err := userCollection.UpdateOne(context.TODO(), filter, update)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to update user information", "error": err.Error()})
return
}

log.Printf("Updated %v Documents!\n", result.ModifiedCount)
c.JSON(http.StatusOK, gin.H{"message": "Questions updated successfully"})
}
Loading