Skip to content
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
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions handlers/admin_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions handlers/centrehead_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion services/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/centrehead_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestCentreHeadLogin_WrongPassword(t *testing.T) {
"email": ch.Email,
"password": "nope",
})
assertStatus(t, rec, 403)
assertStatus(t, rec, 401)
}

// --- CentreHeadForgetPassword -----------------------------------------------
Expand Down
Loading