* Initial Commit for OAuth API This builds and run and return the right error. Need to test it and then adding all users as possible client * Added mising dependency * just compile already... * Fixing template test * Imrpovements Moved db stuff in models Added some tests Added form in modpanel to add/update a client Added controllers for add/update of client * Added Forms + speed improvements Controller oauth client listing + html Controller oauth client delete + messages Messages on comment delete New ES config that disable ES if set to false. Improve load speed on local development Fix a load config bug Fix index admin & translation string sign_out broken by @ewhal * Sanitize empty strig in form array + css Multiple empty array of strings are sanitized for the oauth client create form Added some css for the form display * Upload and Create form works * Fix splitting response types * Removing required on secret when updating * fix travis error * Fix travis template test * Update dependency * Moved to jinzhu instead of azhao * randomizen secret on creation * Final touch on oath api improved display name fix grant form csrf fix login csrf on oauth * Fix gorm test * fix template test * Fixing deleted dependency issue * Make travis faster * Fix typo * Fix csrf for api calls * This shouldn't be exempt * Removing hard coded hash @ewhal Don't forget to replace the hash in tokens.go with another one * Added an example on how to use OAuth middleware * Renamed fosite utils to oauth2 utils
58 lignes
1,9 Kio
Go
58 lignes
1,9 Kio
Go
package govalidator
|
|
|
|
// Iterator is the function that accepts element of slice/array and its index
|
|
type Iterator func(interface{}, int)
|
|
|
|
// ResultIterator is the function that accepts element of slice/array and its index and returns any result
|
|
type ResultIterator func(interface{}, int) interface{}
|
|
|
|
// ConditionIterator is the function that accepts element of slice/array and its index and returns boolean
|
|
type ConditionIterator func(interface{}, int) bool
|
|
|
|
// Each iterates over the slice and apply Iterator to every item
|
|
func Each(array []interface{}, iterator Iterator) {
|
|
for index, data := range array {
|
|
iterator(data, index)
|
|
}
|
|
}
|
|
|
|
// Map iterates over the slice and apply ResultIterator to every item. Returns new slice as a result.
|
|
func Map(array []interface{}, iterator ResultIterator) []interface{} {
|
|
var result = make([]interface{}, len(array))
|
|
for index, data := range array {
|
|
result[index] = iterator(data, index)
|
|
}
|
|
return result
|
|
}
|
|
|
|
// Find iterates over the slice and apply ConditionIterator to every item. Returns first item that meet ConditionIterator or nil otherwise.
|
|
func Find(array []interface{}, iterator ConditionIterator) interface{} {
|
|
for index, data := range array {
|
|
if iterator(data, index) {
|
|
return data
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Filter iterates over the slice and apply ConditionIterator to every item. Returns new slice.
|
|
func Filter(array []interface{}, iterator ConditionIterator) []interface{} {
|
|
var result = make([]interface{}, 0)
|
|
for index, data := range array {
|
|
if iterator(data, index) {
|
|
result = append(result, data)
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// Count iterates over the slice and apply ConditionIterator to every item. Returns count of items that meets ConditionIterator.
|
|
func Count(array []interface{}, iterator ConditionIterator) int {
|
|
count := 0
|
|
for index, data := range array {
|
|
if iterator(data, index) {
|
|
count = count + 1
|
|
}
|
|
}
|
|
return count
|
|
}
|