Merge branch 'master' into production

This commit is contained in:
Andrea Fazzi 2021-04-28 12:52:57 +02:00
commit 9ea4487d4e
3 changed files with 46 additions and 0 deletions

View file

@ -88,6 +88,7 @@ func main() {
conf.Handlers.Permissions = map[string]map[string][]int{
"administrator": map[string][]int{
"User": []int{oef_handlers.PermissionCreate, oef_handlers.PermissionRead, oef_handlers.PermissionReadAll, oef_handlers.PermissionUpdate, oef_handlers.PermissionDelete},
"Contest": []int{oef_handlers.PermissionCreate, oef_handlers.PermissionRead, oef_handlers.PermissionReadAll, oef_handlers.PermissionUpdate, oef_handlers.PermissionDelete},
"Participant": []int{oef_handlers.PermissionCreate, oef_handlers.PermissionRead, oef_handlers.PermissionReadAll, oef_handlers.PermissionUpdate, oef_handlers.PermissionDelete},
"School": []int{oef_handlers.PermissionCreate, oef_handlers.PermissionRead, oef_handlers.PermissionReadAll, oef_handlers.PermissionUpdate, oef_handlers.PermissionDelete},

2
scripts/test_credentials/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.csv
*.xlsx

View file

@ -0,0 +1,43 @@
package main
import (
"flag"
"log"
"git.andreafazzi.eu/andrea/oef/client"
"git.andreafazzi.eu/andrea/oef/orm"
)
func login(url string, user *orm.User) error {
log.Printf("Obtaining token for user %s (%s %s)", user, user.Username, user.Password)
_, err := client.GetToken(url, user.Username, user.Password)
if err != nil {
return err
}
return nil
}
func main() {
username := flag.String("username", "admin", "Username")
password := flag.String("password", "admin", "Password")
flag.Parse()
client, err := client.Dial(flag.Arg(0), *username, *password)
if err != nil {
panic(err)
}
users := make([]*orm.User, 0)
log.Println("Get all users...")
err = client.ReadAll(&users)
if err != nil {
panic(err)
}
for _, user := range users {
login(flag.Arg(0), user)
}
}