Documentation ¶
Index ¶
- Variables
- func CreateRequest(requestType string, initiatorId uint, targetId uint) map[string]interface{}
- func GetDB() *gorm.DB
- func GetGlobalSettings() map[string]interface{}
- func HandleFormingRequest(userId uint, requesterId uint, accept bool) map[string]interface{}
- func HandleJoiningRequest(groupId uint, userId uint, accept bool) map[string]interface{}
- func InitializeGlobalSettings()
- func IsAdmin(userId uint) bool
- func Login(email, password string) map[string]interface{}
- func RequestExists(request Request) bool
- func SaveGlobalSettings(settings map[string]interface{}) map[string]interface{}
- type Account
- type AccountPublic
- type Activity
- type AuthResponse
- type AvailableMentor
- type GlobalSetting
- type Group
- type GroupDetails
- type GroupWithMentors
- type Request
- type TemplateActivity
- type Token
- type UnverifiedActivity
Constants ¶
This section is empty.
Variables ¶
View Source
var JwtAuthentication = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { notAuth := []string{"/api/health", "/api/user/new", "/api/user/login", "/api/global-settings"} requestPath := r.URL.Path for _, value := range notAuth { if value == requestPath { next.ServeHTTP(w, r) return } } if strings.HasPrefix(r.URL.Path, "/api/images") { next.ServeHTTP(w, r) return } response := make(map[string]interface{}) tokenHeader := r.Header.Get("Authorization") if tokenHeader == "" { response = utils.Message(false, "Missing auth token") w.WriteHeader(http.StatusForbidden) utils.Respond(w, response) return } tk := &Token{} token, err := jwt.ParseWithClaims(tokenHeader, tk, func(token *jwt.Token) (interface{}, error) { return []byte(os.Getenv("TOKEN_SECRET")), nil }) if err != nil { response = utils.Message(false, "Malformed authentication token") w.WriteHeader(http.StatusForbidden) utils.Respond(w, response) return } if !token.Valid { response = utils.Message(false, "Token is not valid.") w.WriteHeader(http.StatusForbidden) utils.Respond(w, response) return } ctx := context.WithValue(r.Context(), "user", tk.UserId) r = r.WithContext(ctx) next.ServeHTTP(w, r) }) }
Functions ¶
func CreateRequest ¶
func GetGlobalSettings ¶
func GetGlobalSettings() map[string]interface{}
func HandleFormingRequest ¶
func HandleJoiningRequest ¶
func InitializeGlobalSettings ¶
func InitializeGlobalSettings()
func RequestExists ¶
func SaveGlobalSettings ¶
Types ¶
type Account ¶
type Account struct { gorm.Model Email string `json:"email"` Password string `json:"password"` Name string `json:"name"` Tagline string `json:"tagline"` Degree string `json:"degree"` Year string `json:"year"` Token string `json:"token";gorm:"-"` Role string `json:"role"` GroupId *uint `json:"groupId"` ImageUrl string `json:"imageUrl"` Bio string `json:"bio"` IsVerified *bool `json:"isVerified"` RejectionReason string `json:"rejectionReason"` }
func GetAllUsers ¶
func (*Account) GetPublicInfo ¶
func (account *Account) GetPublicInfo() AccountPublic
func (*Account) SetGroupId ¶
type AccountPublic ¶
type Activity ¶
type Activity struct { gorm.Model GroupId uint `json:"groupId"` TemplateId *uint `json:"templateId"` Name string `json:"name"` Points uint `json:"points"` Time string `json:"time"` Participants pq.Int64Array `json:"participants" gorm:"type:int[]"` Images pq.StringArray `json:"images" gorm:"type:varchar(100)[]"` IsVerified *bool `json:"isVerified"` RejectionReason string `json:"rejectionReason"` }
func GetActivity ¶
type AuthResponse ¶
type AvailableMentor ¶
type AvailableMentor struct { Name string `json:"name"` UserId uint `json:"userId"` ImageUrl string `json:"imageUrl"` HasRequestedYou bool `json:"hasRequestedYou"` YouHaveRequested bool `json:"youHaveRequested"` }
func GetFreeMentors ¶
func GetFreeMentors(userId uint) []AvailableMentor
type GlobalSetting ¶
func (*GlobalSetting) GetValue ¶
func (globalSetting *GlobalSetting) GetValue() interface{}
type Group ¶
type Group struct { gorm.Model Title string `json:"title"` Tagline string `json:"tagline"` Description string `json:"description"` }
func (*Group) GetDetails ¶
func (group *Group) GetDetails() GroupDetails
func (*Group) GetMentors ¶
func (group *Group) GetMentors() GroupWithMentors
type GroupDetails ¶
type GroupDetails struct { Title string `json:"title"` Tagline string `json:"tagline"` Description string `json:"description"` Mentors []AccountPublic `json:"mentors"` Mentees []AccountPublic `json:"mentees"` Requests []AccountPublic `json:"requests"` Activities []Activity `json:"activities"` }
func GetGroupDetails ¶
func GetGroupDetails(groupId uint) *GroupDetails
type GroupWithMentors ¶
type GroupWithMentors struct { Id uint `json:"id"` Title string `json:"title"` Tagline string `json:"tagline"` Description string `json:"description"` Mentors []AccountPublic `json:"mentors"` }
func GetGroups ¶
func GetGroups() []GroupWithMentors
type TemplateActivity ¶
type TemplateActivity struct { gorm.Model Name string `json:"name"` Points uint `json:"points"` RequiredParticipants uint `json:"requiredParticipants"` }
func GetTemplateActivities ¶
func GetTemplateActivities() []TemplateActivity
func GetTemplateActivity ¶
func GetTemplateActivity(id uint) *TemplateActivity
func (*TemplateActivity) Save ¶
func (templateActivity *TemplateActivity) Save()
type UnverifiedActivity ¶
type UnverifiedActivity struct { Name string `json:"name"` ID uint GroupName string `json:"groupName"` }
func GetUnverifiedActivities ¶
func GetUnverifiedActivities() []UnverifiedActivity
Click to show internal directories.
Click to hide internal directories.