Skip to content

Commit c7288f7

Browse files
committed
refactor: update function name, update struct type
1 parent f8db5bc commit c7288f7

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

controllers/oauth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func OAuth(w http.ResponseWriter, r *http.Request) {
8383

8484
// Check if the user is a organiser
8585

86-
isOrganiser := utils.CheckUserOrgs(accessToken, userInfo.Username)
86+
isOrganiser := utils.IsUserExecutive(accessToken, userInfo.Username)
8787
if isOrganiser {
8888

8989
jwtString, err := utils.GenerateLoginJwtString(utils.LoginJwtFields{

controllers/organiser.go

+16-22
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,9 @@ type AcceptRejectProject struct {
2020
}
2121

2222
type ProjectOrg struct {
23-
Id uint `json:"id"`
24-
Name string `json:"name"`
25-
Description string `json:"description"`
26-
Tags []string `json:"tags"`
27-
RepoLink string `json:"repo_link"`
28-
CommChannel string `json:"comm_channel"`
29-
ReadmeLink string `json:"readme_link"`
30-
Mentor Mentor `json:"mentor"`
31-
SecondaryMentor Mentor `json:"secondary_mentor"`
32-
ProjectStatus bool `json:"project_status"`
33-
StatusRemark string `json:"status_remark"`
23+
ProjectStatus bool `json:"project_status"`
24+
StatusRemark string `json:"status_remark"`
25+
Project
3426
}
3527

3628
func newProjectOrg(dbProject *models.Project) ProjectOrg {
@@ -40,17 +32,19 @@ func newProjectOrg(dbProject *models.Project) ProjectOrg {
4032
}
4133

4234
return ProjectOrg{
43-
Id: dbProject.ID,
44-
Name: dbProject.Name,
45-
Description: dbProject.Description,
46-
Tags: tags,
47-
RepoLink: dbProject.RepoLink,
48-
CommChannel: dbProject.CommChannel,
49-
ReadmeLink: dbProject.ReadmeLink,
50-
Mentor: newMentor(&dbProject.Mentor),
51-
SecondaryMentor: newMentor(&dbProject.SecondaryMentor),
52-
ProjectStatus: dbProject.ProjectStatus,
53-
StatusRemark: dbProject.StatusRemark,
35+
Project: Project{
36+
Id: dbProject.ID,
37+
Name: dbProject.Name,
38+
Description: dbProject.Description,
39+
Tags: tags,
40+
RepoLink: dbProject.RepoLink,
41+
CommChannel: dbProject.CommChannel,
42+
ReadmeLink: dbProject.ReadmeLink,
43+
Mentor: newMentor(&dbProject.Mentor),
44+
SecondaryMentor: newMentor(&dbProject.SecondaryMentor),
45+
},
46+
ProjectStatus: dbProject.ProjectStatus,
47+
StatusRemark: dbProject.StatusRemark,
5448
}
5549
}
5650

utils/oauth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func GetOauthUserInfo(accessToken string) (*GHUserInfo, error) {
130130
return &userInfo, nil
131131
}
132132

133-
func CheckUserOrgs(accessToken string, username string) bool {
133+
func IsUserExecutive(accessToken string, username string) bool {
134134

135135
client := http.Client{}
136136
url := fmt.Sprintf("https://api.github.com/orgs/kossiitkgp/teams/executies/memberships/%s", username)

0 commit comments

Comments
 (0)