當前位置: 首頁>>代碼示例>>Golang>>正文


Golang structs.AuthToken類代碼示例

本文整理匯總了Golang中structs.AuthToken的典型用法代碼示例。如果您正苦於以下問題:Golang AuthToken類的具體用法?Golang AuthToken怎麽用?Golang AuthToken使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AuthToken類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: GetOccupancy

/*
 * Gets the current occupancy (people that have bought daypasses) for a given day.
 */
func GetOccupancy(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()

	var auth S.AuthToken
	var date string

	for k, v := range r.Form {
		if k == "user" {
			auth.User = strings.Join(v, "")
		} else if k == "date" {
			date = strings.Join(v, "")
		} else {
			auth.Code = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) {
		fmt.Fprintf(w, "Please login")
		return
	}

	fmt.Fprintf(w, db.GetOccupancy(auth, date))

	//if db.HasHotel(auth) {
	//} else {
	//fmt.Fprintf(w, "You do not work for a hotel")
	//}
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:31,代碼來源:occupancy.go

示例2: Validate

//Invoked by dispatch to authenticate a user
func Validate(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()

	var token S.Token
	var auth S.AuthToken

	for k, v := range r.Form {
		if k == "hotel" {
			token.Hotel = strings.Join(v, "")
		} else if k == "code" {
			token.Code = strings.Join(v, "")
		} else if k == "user" {
			auth.User = strings.Join(v, "")
		} else {
			auth.Code = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) {
		fmt.Fprintf(w, "Please login")
		return
	}

	if db.ValidateToken(token) {
		fmt.Printf("[SUCCESS] %s checked into %s\n", auth.User, token.Hotel)
		fmt.Fprintf(w, "VALID DAYCATION")
	} else {
		fmt.Fprintf(w, "INVALID!")
	}
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:31,代碼來源:validation.go

示例3: SetMaxOccupancy

func SetMaxOccupancy(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")

	r.ParseForm()

	var auth S.AuthToken

	var maxOccupancy string
	var date string
	hotel := "none"

	for k, v := range r.Form {
        if k == "user" {
			auth.User = strings.Join(v, "")
		} else if k == "date" {
			date = strings.Join(v, "")
		} else if k == "maxOccupancy" {
			maxOccupancy = strings.Join(v, "")
		} else if k == "hotel" {
			hotel = strings.Join(v, "")
		} else if k == "code" {
			auth.Code = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) || hotel == "none" {
		fmt.Fprintf(w, "{\"Please login\"}")
		return
	}


	maxOccupancyInt, err := strconv.Atoi(maxOccupancy)
	if err != nil {
		fmt.Fprintf(w, "{\"ERROR\":1}")
		return
	}

	fail := "0"

	if db.SetMaxOccupancy(date, hotel, maxOccupancyInt) {
		fail = "1"
	}
	fmt.Fprintf(w, "{" + fail + "}")

	// if db.HasHotel(auth) {
	// 	fmt.Fprintf(w, db.SetMaxOccupancy(auth, maxOccupancy, date))
	// } else {
	// 	fmt.Fprintf(w, "You do not work for a hotel")
	// }
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:51,代碼來源:occupancy.go

示例4: GetMaxOccupancy

/*
 * Gets the max occupancy for a given day.
 */
func GetMaxOccupancy(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")

	r.ParseForm()

	var auth S.AuthToken
	var date string

	hotel := "none"

	for k, v := range r.Form {
       	if k == "user" {
			auth.User = strings.Join(v, "")
		} else if k == "date" {
			date = strings.Join(v, "")
		} else if k == "code" {
			auth.Code = strings.Join(v, "")
		} else if k == "hotel" {
			hotel = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) || hotel == "none" {
		fmt.Fprintf(w, "{\"Please login\"}")
		return
	}


	occupancyString := strconv.Itoa(db.GetMaxOccupancy(date, hotel))
	
	//fmt.Fprintf(w, "10")
	fmt.Fprintf(w, occupancyString)

	// real one here 
	//fmt.Fprintf(w, occupancyString)

	// if db.HasHotel(auth) {
	// 	fmt.Fprintf(w, db.GetMaxOccupancy(auth, date))
	// } else {
	// 	fmt.Fprintf(w, "You do not work for a hotel")
	// }
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:46,代碼來源:occupancy.go

示例5: Check

//Invoked by dispatch to Check In a guest
func Check(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")

	r.ParseForm()

	var customer string
	var callback string
	var hotel string
	var auth S.AuthToken
	var checkin string

	for k, v := range r.Form {
		if k == "guestId" {
			customer = strings.Join(v, "")
		} else if k == "user" {
			auth.User = strings.Join(v, "")
		} else if k == "code" {
			auth.Code = strings.Join(v, "")
		} else if k == "callback" {
			callback = strings.Join(v, "")
		} else if k == "checkedIn" {
			checkin = strings.Join(v, "")
		} else if k == "hotel" {
			hotel = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) || customer == "" {
		fmt.Fprintf(w, "{\"Please login\"}")
		return
	}

	fmt.Println("Checked in " + customer)

	check, _ := strconv.ParseBool(checkin)
	fmt.Println(db.CheckIn(hotel, customer, check))

	fmt.Fprintf(w, callback+"(\"SUCCESS\")")
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:41,代碼來源:checkin.go

示例6: List

//Invoked by dispatch to authenticate a user
func List(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()

	var auth S.AuthToken
	for k, v := range r.Form {
		if k == "user" {
			auth.User = strings.Join(v, "")
		} else {
			auth.Code = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) {
		fmt.Fprintf(w, "Please login")
		return
	}

	if db.HasHotel(auth) {
		fmt.Fprintf(w, db.GetPasses(auth))
	} else {
		fmt.Fprintf(w, "You do not work for a hotel")
	}
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:24,代碼來源:list.go

示例7: List

//Invoked by dispatch to authenticate a user
func List(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")

	r.ParseForm()

	var callback string
	var auth S.AuthToken
	hotel := "none"
	for k, v := range r.Form {
		if k == "user" {
			auth.User = strings.Join(v, "")
		} else if k == "code" {
			auth.Code = strings.Join(v, "")
		} else if k == "callback" {
			callback = strings.Join(v, "")
		} else if k == "hotel" {
			hotel = strings.Join(v, "")
		}
	}

	if !db.Authenticate(auth) || hotel == "none" {
		fmt.Println(auth.User + " attempted to access list")
		fmt.Fprintf(w, "{\"Please login\"}")
		return
	}

	///fmt.Fprintf(w, callback + "(" + db.GetPasses(hotel, auth) + ")")

	//hasHotel is causing problems for the metropolitan
	if db.HasHotel(auth) {
		fmt.Fprintf(w, callback+"("+db.GetPasses(hotel, auth)+")")
	} else {
		fmt.Fprintf(w, "You do not work for a hotel")
	}
}
開發者ID:daycationapp,項目名稱:infrastructure,代碼行數:37,代碼來源:list.go


注:本文中的structs.AuthToken類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。