Commits

Enmanuel Rivera committed 90050f8

Bug fixes

  • Participants
  • Parent commits 776723e
  • Branches develop

Comments (0)

Files changed (5)

File src/gxs3/godfather/data/BaseDbDao.go

 	}
 
 	var job = parsed.(map[string]interface{})
-	var result = make(map[string]string)
+	var result = make(map[string]string, len(job))
 
 	for key, value := range job {
 		result[key] = value.(string)
 	return result, nil
 }
 
-//Returns the template which is currently being used by this DAO
-func (dbdao *BaseDbDao) Template() *SqlTemplate {
-	return dbdao.template
+/*
+ Returns the template which is currently being used by this DAO
+*/
+func (dao *BaseDbDao) Template() *SqlTemplate {
+	return dao.template
 }
 
 /*
  When the DAO was initialized a query file was loaded. This function will search the loaded queries for one
  that matches the provided key.
 */
-func (dbdao *BaseDbDao) GetQuery(key string) string {
-	return dbdao.dictionary[key]
+func (dao *BaseDbDao) GetQuery(key string) string {
+	return dao.dictionary[key]
 }
 
 /*

File src/gxs3/godfather/data/PrivilegeDao.go

 */
 func (pd *PrivilegeDao) Sync(group uint, granted []uint) (uint, error) {
 	var txt, err = NewTxTemplate(pd.Template())
-	var total uint = 0
+	var total uint = 1
 
 	if err != nil {
 		return 0, err

File src/gxs3/godfather/server/AuthService.go

 	as.authDao, err[0] = data.NewAuthDao(template, dictionary)
 	as.userDao, err[1] = data.NewUserDao(template, dictionary)
 	as.privDao, err[2] = data.NewPrivilegeDao(template, dictionary)
-	as.sessionTimeout = int(sessionTimeoutFl)
+	as.sessionTimeout = int(sessionTimeoutFl) * 60
 
 	for _, e := range err {
 		if e != nil {
 
 	privs, err := as.privDao.GetUserGranted(user.Id())
 
-	if err != nil {
+	if err != nil && err != data.NOT_FOUND {
 		http.Error(writer, "Error attempting to retrieve privileges granted to the user: "+err.Error(), INTERNAL_SERVER_ERROR)
 		return
 	}

File src/gxs3/godfather/server/Context.go

 		panic("Environment variable " + ROOT + " has not been set. Please set this to the application path.")
 	}
 
-	var file, err = os.Open(root + CONFIG_PATH)
+	if _, err := os.Stat(root + CONFIG_PATH); os.IsNotExist(err) {
+		panic("Count not find config file at: " + root + CONFIG_PATH)
+	}
+
+	file, err := os.Open(root + CONFIG_PATH)
 
 	if err != nil {
 		return nil, err

File src/gxs3/godfather/server/PrivilegeService.go

 	ps.GetCollection(writer, req, PRIV_PRIV_VIEW, getUserGranted, ps.Base().EncodeModels(encodePrivilege))
 }
 
+/*
+ Synchronizes the privileges that have been granted to a group. Removes all existing grants and replaces them with
+ the grants provided in the request. An array of IDs is expected in the post body with privileges to grant.
+ Method: POST - URI: /priv?group={group}
+*/
 func (ps *PrivilegeService) sync(writer http.ResponseWriter, req *http.Request) {
 	var grantedStr, err = ioutil.ReadAll(req.Body)
 
 	var grants = make([]uint, len(array))
 
 	for cont, grant := range array {
-		grants[cont] = uint(grant.(float64))
+		value, ok := grant.(float64)
+
+		if !ok {
+			return nil, errors.New("At least one value in grant array is not a number")
+		}
+
+		grants[cont] = uint(value)
 	}
 
 	return grants, nil