Skip to content

Commit 83d1b8d

Browse files
committed
fix hp
1 parent 3a18afa commit 83d1b8d

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

middlewares/jwt.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ var JwtMiddlewareStruct = jwt.GinJWTMiddleware{
5050
IdentityHandler: func(c *gin.Context) interface{} {
5151
claims := jwt.ExtractClaims(c)
5252
return &models.JWTTeam{
53-
TeamName: claims[identityKey].(string),
53+
Login: claims[identityKey].(string),
54+
TeamName: claims["name"].(string),
55+
Address: claims["address"].(string),
5456
}
5557
},
5658
Authenticator: func(c *gin.Context) (interface{}, error) {

models/scoreboard.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ type Score struct {
1313
}
1414

1515
type ScoreService struct {
16-
SLA float64 `bson:"sla" json:"sla"`
17-
State int `bson:"state" json:"state"`
18-
Gained int `bson:"gained" json:"gained"`
19-
Lost int `bson:"lost" json:"lost"`
20-
HP int `bson:"hp" json:"hp"`
21-
Cost int `bson:"cost" json:"cost"`
16+
SLA float64 `bson:"sla" json:"sla"`
17+
State int `bson:"state" json:"state"`
18+
Gained int `bson:"gained" json:"gained"`
19+
Lost int `bson:"lost" json:"lost"`
20+
HP int `bson:"hp" json:"hp"`
21+
TotalHP int `bson:"total_hp" json:"total_hp"`
22+
Cost int `bson:"cost" json:"cost"`
2223
}
2324

2425
type OutputScoreboard struct {

routers/openvpn.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ func DownloadVpnConfig(username string) (string, error) {
5353
log.Fatal(err)
5454
}
5555

56-
vpnConfig := string(responseData)
57-
58-
return vpnConfig, nil
56+
return string(responseData), nil
5957
}
6058

6159
func (vpnRoute *VpnRoute) WriteTeamsRoutes() error {

routers/team.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"log"
1313
"net"
1414
"net/http"
15+
"strings"
1516
"time"
1617
)
1718

@@ -109,11 +110,12 @@ func CreateTeam(c *gin.Context) {
109110
c.JSON(http.StatusBadRequest, gin.H{"detail": hashErr.Error()})
110111
return
111112
}
112-
113+
login := slug.Make(team.Name)
114+
login = strings.Replace(login, "-", "_", -1)
113115
dbTeam := &models.Team{
114116
ID: primitive.NewObjectID(),
115117
Name: team.Name,
116-
Login: slug.Make(team.Name),
118+
Login: login,
117119
Address: ipAddress,
118120
Hash: hash,
119121
SshPubKey: team.SshPubKey,
@@ -133,6 +135,7 @@ func CreateTeam(c *gin.Context) {
133135
}
134136
c.JSON(http.StatusOK, gin.H{
135137
"message": fmt.Sprintf("The team %s created", team.Name),
138+
"login": login,
136139
})
137140
}
138141

0 commit comments

Comments
 (0)