/
unban.go
47 lines (38 loc) · 1.16 KB
/
unban.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package api
import (
"github.com/gin-gonic/gin"
"../players/auth"
"../players"
"../bans"
)
func HttpReqUnban(c *gin.Context) {
mapResponse := make(map[string]interface{});
sCookieSessID, errCookieSessID := c.Cookie("session_id");
sSteamID64 := c.Query("steamid64");
mapResponse["success"] = false;
if (sSteamID64 != "") {
if (errCookieSessID == nil && sCookieSessID != "") {
oSession, bAuthorized := auth.GetSession(sCookieSessID, c.Query("csrf"));
if (bAuthorized) {
players.MuPlayers.RLock();
iAccess := players.MapPlayers[oSession.SteamID64].Access;
players.MuPlayers.RUnlock();
if (iAccess == 4) { //only admin can unban
bans.ChanUnbanManual <- sSteamID64;
mapResponse["success"] = true;
} else {
mapResponse["error"] = "You dont have access to this command";
}
} else {
mapResponse["error"] = "Please authorize first";
}
} else {
mapResponse["error"] = "Please authorize first";
}
} else {
mapResponse["error"] = "Bad parameters";
}
c.Header("Access-Control-Allow-Origin", c.Request.Header.Get("origin"));
c.Header("Access-Control-Allow-Credentials", "true");
c.JSON(200, mapResponse);
}