From 593d317229adacd133f37e8fff2ac099723dabd5 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Sat, 30 May 2026 16:14:58 +0530 Subject: [PATCH 1/4] fix: fixed typo --- handlers/admin_post.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handlers/admin_post.go b/handlers/admin_post.go index 99f6a56..3d0f266 100644 --- a/handlers/admin_post.go +++ b/handlers/admin_post.go @@ -113,7 +113,7 @@ func (h* AdminHandler) GetAEPosts (c *gin.Context) { if strings.Contains(string(admin.Position), "Civil") { postType = "Civil" } else { - postType = "Electical" + postType = "Electrical" } var facultyPosts []models.FacultyPost @@ -188,7 +188,7 @@ func (h* AdminHandler) GetJEPosts (c *gin.Context) { if strings.Contains(string(admin.Position), "Civil") { postType = "Civil" } else { - postType = "Electical" + postType = "Electrical" } var facultyPosts []models.FacultyPost From af78a0bf0ea303c00153ad8b9ef0924ef056fdc0 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Sat, 30 May 2026 16:15:56 +0530 Subject: [PATCH 2/4] fix: now returns err --- services/email.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/email.go b/services/email.go index ae4a6a6..761f63a 100644 --- a/services/email.go +++ b/services/email.go @@ -103,7 +103,7 @@ func SendPasswordResetMail(userID uint, email, role string) error { err = SendMail(email, "Reset cms account password", mail) if err != nil { - return nil + return err } log.Printf("Password reset link sent to %s", email) return nil From 2d75f44512f98dc726884f326a04a283e3d9c992 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Sat, 30 May 2026 16:25:32 +0530 Subject: [PATCH 3/4] fix: status codes --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++++ handlers/centrehead_auth.go | 8 ++++---- 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..93a727a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: CI + +on: + pull_request: + branches: [main] + push: + branches: [main] + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + + - name: Download dependencies + run: go mod download + + - name: Run tests + run: go test ./test/... -v -count=1 diff --git a/handlers/centrehead_auth.go b/handlers/centrehead_auth.go index b8e83c6..671a827 100644 --- a/handlers/centrehead_auth.go +++ b/handlers/centrehead_auth.go @@ -16,7 +16,7 @@ import ( // CentreHeadSignup registers the head of adminstrations. // On success, sends a verification email with a JWT token link. -func (h *AuthHandler) CentreHeadSignup (c *gin.Context) { +func (h *AuthHandler) CentreHeadSignup(c *gin.Context) { var inputs models.CentreHeadSignup if err := c.ShouldBindJSON(&inputs); err != nil { @@ -73,7 +73,7 @@ func (h *AuthHandler) CentreHeadSignup (c *gin.Context) { // CentreHeadLogin authenticates the head of administrations using email and password. // On success, signs a JWT and stores it in an httpOnly cookie. -func (h *AuthHandler) CentreHeadLogin (c *gin.Context) { +func (h *AuthHandler) CentreHeadLogin(c *gin.Context) { var inputs models.CentreHeadLogin if err := c.ShouldBindJSON(&inputs); err != nil { @@ -88,7 +88,7 @@ func (h *AuthHandler) CentreHeadLogin (c *gin.Context) { c.JSON(404, gin.H{"error": "user not found"}) return } - c.JSON(404, gin.H{"error": "internal server error"}) + c.JSON(500, gin.H{"error": "internal server error"}) return } @@ -99,7 +99,7 @@ func (h *AuthHandler) CentreHeadLogin (c *gin.Context) { err := bcrypt.CompareHashAndPassword([]byte(head.Password), []byte(inputs.Password)) if err != nil { - c.JSON(403, gin.H{"error": "incorrect password"}) + c.JSON(401, gin.H{"error": "incorrect password"}) return } From b4de6a03b07f7d9e5b8c7da38613a82bd2763662 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Sat, 30 May 2026 16:31:46 +0530 Subject: [PATCH 4/4] fix: status code in tests --- test/centrehead_auth_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/centrehead_auth_test.go b/test/centrehead_auth_test.go index a6aac94..e9808bd 100644 --- a/test/centrehead_auth_test.go +++ b/test/centrehead_auth_test.go @@ -93,7 +93,7 @@ func TestCentreHeadLogin_WrongPassword(t *testing.T) { "email": ch.Email, "password": "nope", }) - assertStatus(t, rec, 403) + assertStatus(t, rec, 401) } // --- CentreHeadForgetPassword -----------------------------------------------