Add initial_name field in DB
This commit is contained in:
parent
d30b4946b3
commit
467641f4f2
3 changed files with 37 additions and 21 deletions
|
@ -22,7 +22,7 @@ func nginxGenTeam() (string, error) {
|
|||
} else {
|
||||
ret := ""
|
||||
for _, team := range teams {
|
||||
ret += fmt.Sprintf(" if ($ssl_client_s_dn ~ \"/C=FR/ST=France/O=Epita/OU=SRS/CN=%s\") { set $team %d; }\n", team.Name, team.Id)
|
||||
ret += fmt.Sprintf(" if ($ssl_client_s_dn ~ \"/C=FR/ST=France/O=Epita/OU=SRS/CN=%s\") { set $team %d; }\n", team.InitialName, team.Id)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
|
@ -63,10 +63,14 @@ type uploadedMember struct {
|
|||
|
||||
func listTeam(args []string, body []byte) (interface{}, error) {
|
||||
if len(args) >= 2 {
|
||||
if tid, err := strconv.Atoi(string(args[0])); err != nil {
|
||||
return nil, err
|
||||
var team *fic.Team
|
||||
if tid, err := strconv.Atoi(args[0]); err != nil {
|
||||
if t, err := fic.GetTeamByInitialName(args[0]); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
team = &t
|
||||
}
|
||||
} else {
|
||||
var team *fic.Team
|
||||
if tid == 0 {
|
||||
team = nil
|
||||
} else if t, err := fic.GetTeam(tid); err != nil {
|
||||
|
@ -75,15 +79,16 @@ func listTeam(args []string, body []byte) (interface{}, error) {
|
|||
team = &t
|
||||
}
|
||||
|
||||
if args[1] == "my.json" {
|
||||
return fic.MyJSONTeam(team, true)
|
||||
} else if args[1] == "wait.json" {
|
||||
return fic.MyJSONTeam(team, false)
|
||||
} else if args[1] == "certificate" && team != nil {
|
||||
return CertificateAPI(*team, args[2:])
|
||||
} else if args[1] == "name" {
|
||||
return team.Name, nil
|
||||
}
|
||||
}
|
||||
|
||||
if args[1] == "my.json" {
|
||||
return fic.MyJSONTeam(team, true)
|
||||
} else if args[1] == "wait.json" {
|
||||
return fic.MyJSONTeam(team, false)
|
||||
} else if args[1] == "certificate" && team != nil {
|
||||
return CertificateAPI(*team, args[2:])
|
||||
} else if team != nil && args[1] == "name" {
|
||||
return team.Name, nil
|
||||
}
|
||||
} else if len(args) == 1 {
|
||||
if args[0] == "teams.json" {
|
||||
|
|
Reference in a new issue